diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml new file mode 100644 index 000000000..ef97bfea4 --- /dev/null +++ b/.github/workflows/reusable-build.yml @@ -0,0 +1,109 @@ +name: Build Openocd for all platforms +on: [workflow_call] + +jobs: + + build-mac-14-arm: + runs-on: macos-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Install Dependencies + run: | + brew update + brew install automake + brew install texinfo + brew install libtool + export PATH=/usr/local/opt/texinfo/bin:$PATH + - name: build-openocd + run: | + ./build-openocd.sh + - name: Publish OpenOCD packaged for mac + uses: actions/upload-artifact@v4 + with: + name: artifact-mac-14-arm-release + path: ./openocd + if-no-files-found: error + + build-mac-12: + runs-on: macos-12 + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Install Dependencies + run: | + brew update + brew install automake + brew install texinfo + export PATH=/usr/local/opt/texinfo/bin:$PATH + - name: build-openocd + run: | + ./build-openocd.sh + - name: Publish OpenOCD packaged for mac + uses: actions/upload-artifact@v4 + with: + name: artifact-mac-12-release + path: ./openocd + if-no-files-found: error + + build-linux-22-04: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install libudev-dev + sudo apt-get install libtool + sudo apt-get install autoconf + - name: build-openocd + run: | + ./build-openocd.sh + - name: Publish OpenOCD packaged for linux + uses: actions/upload-artifact@v4 + with: + name: artifact-linux-22-04-release + path: ./openocd + if-no-files-found: error + + build-linux-20-04: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install libudev-dev + sudo apt-get install libtool + sudo apt-get install autoconf + - name: build-openocd + run: | + ./build-openocd.sh + - name: Publish OpenOCD packaged for linux + uses: actions/upload-artifact@v4 + with: + name: artifact-linux-20-04-release + path: ./openocd + if-no-files-found: error + + build-windows: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: true + install: git autotools mingw-w64-x86_64-cmake mingw-w64-ucrt-x86_64-gcc + - name: build-openocd + run: | + ./build-openocd.sh + - name: Publish OpenOCD packaged for windows + uses: actions/upload-artifact@v4 + with: + name: artifact-windows-release + path: ./openocd + if-no-files-found: error diff --git a/.github/workflows/reusable-publish.yml b/.github/workflows/reusable-publish.yml new file mode 100644 index 000000000..d08457c42 --- /dev/null +++ b/.github/workflows/reusable-publish.yml @@ -0,0 +1,20 @@ +name: Publish +on: + workflow_call: + inputs: + build_run_id: + description: 'The run id of the build job' + required: true + type: string + +jobs: + download-artifacts: + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: dawidd6/action-download-artifact@v3.1.4 + with: + run_id: ${{ inputs.build_run_id }} + path: build/ + - name: ls build + run: ls build diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 269976f8c..b9fb5e3bd 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -8,108 +8,12 @@ on: workflow_dispatch: jobs: - - build-mac-14-arm: - runs-on: macos-latest - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Install Dependencies - run: | - brew update - brew install automake - brew install texinfo - brew install libtool - export PATH=/usr/local/opt/texinfo/bin:$PATH - - name: build-openocd - run: | - ./build-openocd.sh - - name: Publish OpenOCD packaged for mac - uses: actions/upload-artifact@v4 - with: - name: artifact-mac-14-arm-release - path: ./openocd - if-no-files-found: error - - build-mac-12: - runs-on: macos-12 - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Install Dependencies - run: | - brew update - brew install automake - brew install texinfo - export PATH=/usr/local/opt/texinfo/bin:$PATH - - name: build-openocd - run: | - ./build-openocd.sh - - name: Publish OpenOCD packaged for mac - uses: actions/upload-artifact@v4 - with: - name: artifact-mac-12-release - path: ./openocd - if-no-files-found: error - - build-linux-22-04: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install Dependencies - run: | - sudo apt-get update - sudo apt-get install libudev-dev - sudo apt-get install libtool - sudo apt-get install autoconf - - name: build-openocd - run: | - ./build-openocd.sh - - name: Publish OpenOCD packaged for linux - uses: actions/upload-artifact@v4 - with: - name: artifact-linux-22-04-release - path: ./openocd - if-no-files-found: error - - build-linux-20-04: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Install Dependencies - run: | - sudo apt-get update - sudo apt-get install libudev-dev - sudo apt-get install libtool - sudo apt-get install autoconf - - name: build-openocd - run: | - ./build-openocd.sh - - name: Publish OpenOCD packaged for linux - uses: actions/upload-artifact@v4 - with: - name: artifact-linux-20-04-release - path: ./openocd - if-no-files-found: error - - build-windows: - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - steps: - - uses: actions/checkout@v4 - - uses: msys2/setup-msys2@v2 - with: - msystem: UCRT64 - update: true - install: git autotools mingw-w64-x86_64-cmake mingw-w64-ucrt-x86_64-gcc - - name: build-openocd - run: | - ./build-openocd.sh - - name: Publish OpenOCD packaged for windows - uses: actions/upload-artifact@v4 - with: - name: artifact-windows-release - path: ./openocd - if-no-files-found: error + call-build: + uses: ./.github/workflows/reusable-build.yml + secrets: inherit + call-publish: + uses: ./.github/workflows/reusable-publish.yml + secrets: inherit + needs: call-build + with: + build_run_id: ${{ github.run_id }} diff --git a/.gitignore b/.gitignore index 103dad2c7..57e9f1bdf 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,5 @@ GTAGS # A compile_commands.json can be generated using bear and will help tools such # as clangd to locate header files and use correct $CFLAGS compile_commands.json + +build/ diff --git a/compress-release.sh b/compress-release.sh new file mode 100644 index 000000000..a3edd8727 --- /dev/null +++ b/compress-release.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Directory path +dir_path=${1:-"./build"} + +# Iterate over each folder in the specified directory +for folder in "$dir_path"/openocd-*; do + if [[ -d $folder ]]; then + # Create the tar.gz archive + tar -czf "${folder}.tar.gz" -C "$dir_path" "$(basename "$folder")" + echo "Created archive: ${folder}.tar.gz" + else + echo "Skipping non-directory: $folder" + fi +done diff --git a/generate-manifest.sh b/generate-manifest.sh new file mode 100644 index 000000000..a886b1c44 --- /dev/null +++ b/generate-manifest.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Read the version from the version file +version=$(cat version) +# Directory containing the files +dir_path=${1:-"./build"} + +# Function to generate manifest.json content +generate_manifest() { + platform=$1 + arch=$2 + new_path=$3 + name=$4 + version=$5 + sha256=$6 + +echo "platform: $platform" + cat < ${dir_path}/${new_path}/${name}-${version}-manifest.json +{ + "name": "${name}", + "version": "${version}", + "main": "./bin", + "url": "https://binaries.particle.io/openocd/${platform}/${arch}/${version}.tar.gz", + "sha256": "${sha256}" +} +EOL +} + +# Iterate over each file and generate the manifest.json +for file in "$dir_path"/*.tar.gz; do + filename=$(basename -- "$file") + # Extract platform and arch from the filename + echo "doing something" + platform=$(echo $filename | awk -F '-' '{print $2}') + arch=$(echo $filename | awk -F '-' '{print $3}') + + if [[ -z $platform || -z $arch ]]; then + echo "Unknown file pattern: $filename" + continue + fi + + # Define name + name="openocd" + + # Generate the new file name without the extension + new_file_name="${name}-${version}" + new_path="${name}-${platform}-${arch}" + # Create a directory for the current file to store the manifest.json + echo "creating directory ${dir_path}/${new_path}" + echo ${new_file_name} + echo ${new_path} + mkdir -p "${dir_path}/${new_path}" + + + # Copy the original file to the new directory + cp "$file" "${dir_path}/${new_path}/${new_file_name}.tar.gz" + + # Calculate the SHA-256 checksum + sha256=$(sha256sum "$file" | awk '{ print $1 }') + + # Generate the manifest.json for the current file + generate_manifest "$platform" "$arch" "$new_path" "$name" "$version" "$sha256" + echo "Generated ${dir_path}/${new_path}/${new_file_name}/${name}-${version}-manifest.json" +done diff --git a/version b/version new file mode 100644 index 000000000..874adaa6d --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.12.0-particle-d8e1d63