From 275343d64dcb80268e7b40a3443e01fcbfec3d48 Mon Sep 17 00:00:00 2001 From: Balaji Srinivasan Date: Thu, 6 Jun 2024 19:20:34 +0200 Subject: [PATCH] workflow: Add workflow to attach release assets When a release is created this new workflow calls the other build and test workflows and uploads the tested artifacts into github release. The existing workflows were modified to make them callable from other workflows. Build workflow now uploads the artifacts so that they can be added to the release. The build workflow uploads the hex, bin and the .config file. The names of the files will have the sha if built from main and the tag name if built from a tag. Signed-off-by: Balaji Srinivasan --- .github/workflows/attach_release_assets.yml | 32 +++++++++++++++++++++ .github/workflows/build.yml | 30 +++++++++++++++++-- .github/workflows/dfu_check.yml | 1 + .github/workflows/on_target.yml | 2 ++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/attach_release_assets.yml diff --git a/.github/workflows/attach_release_assets.yml b/.github/workflows/attach_release_assets.yml new file mode 100644 index 00000000..c6224e11 --- /dev/null +++ b/.github/workflows/attach_release_assets.yml @@ -0,0 +1,32 @@ +# Workflow that attaches additional assets to github release. +name: Attach Release Assets + +on: + release: + types: [created] + +jobs: + trigger-build: + uses: ./.github/workflows/build.yml + + trigger-dfu-check: + uses: ./.github/workflows/dfu_check.yml + + trigger-target-test: + uses: ./.github/workflows/on_target.yml + + attach-assets: + runs-on: ubuntu-22.04 + # Only make a release if the above jobs are passing + needs: [trigger-build, trigger-dfu-check, trigger-target-test] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: firmware + + - name: Deploy release to github + uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + files: hello.nrfcloud.com-*.* diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd503087..2a6cfaa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: Build on: + workflow_call: push: branches: - main @@ -33,6 +34,31 @@ jobs: pip install -r nrf/scripts/requirements-build.txt - name: Build firmware - working-directory: thingy91x-oob + working-directory: thingy91x-oob/app + run: | + west build -b thingy91x/nrf9151/ns -p + + - name: Set VERSION + shell: bash + run: | + if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + else + echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV + fi + + + - name: Rename artifacts + working-directory: thingy91x-oob/app/build run: | - west twister -T app -v --inline-logs --integration + cp merged.hex hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app.hex + cp app/zephyr/.config hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app.config + cp app/zephyr/zephyr.signed.bin hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app_update_signed.bin + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: firmware + if-no-files-found: error + path: | + thingy91x-oob/app/build/hello.nrfcloud.com-*.* diff --git a/.github/workflows/dfu_check.yml b/.github/workflows/dfu_check.yml index 6cb57770..5b8868be 100644 --- a/.github/workflows/dfu_check.yml +++ b/.github/workflows/dfu_check.yml @@ -1,6 +1,7 @@ name: DFU image compatibility check on: + workflow_call: push: branches: - main diff --git a/.github/workflows/on_target.yml b/.github/workflows/on_target.yml index bd633a6f..ce9b58ca 100644 --- a/.github/workflows/on_target.yml +++ b/.github/workflows/on_target.yml @@ -1,6 +1,7 @@ name: On_target on: + workflow_call: workflow_dispatch: inputs: run_test: @@ -48,6 +49,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: oob-t91x-hex + if-no-files-found: error path: thingy91x-oob/build/merged.hex test: