Skip to content

Commit 7d44053

Browse files
committed
ci: reuse build for release assets
Reuse the build artifacts from the test workflow for the release assets. Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
1 parent 049e277 commit 7d44053

2 files changed

Lines changed: 34 additions & 12 deletions

File tree

.github/workflows/attach_release_assets.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,46 @@ on:
1010
types: [created]
1111

1212
jobs:
13-
build:
14-
uses: ./.github/workflows/build.yml
15-
secrets: inherit
16-
with:
17-
build_bl_update: true
18-
build_debug: true
19-
memfault_sw_type: "hello.nrfcloud.com"
20-
2113
attach-assets:
2214
runs-on: ubuntu-24.04
23-
needs: [build]
2415
steps:
2516
- name: Checkout
2617
uses: actions/checkout@v4
2718

28-
- name: Download artifact
19+
- name: Set up the GitHub CLI
20+
uses: actions/gh-cli@v1
21+
22+
- name: Find Workflow Run ID for Build
23+
id: find_run_id
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
tag_name="${{ github.event.release.tag_name }}"
28+
workflow_id="test.yml"
29+
30+
# Get workflow runs for the specified workflow ID and tag name
31+
response=$(gh api repos/${{ github.repository }}/actions/workflows/$workflow_id/runs \
32+
-F event=push \
33+
-F branch="$tag_name")
34+
35+
# Extract the run ID of the latest workflow run on the specified tag
36+
run_id=$(echo "$response" | jq -r '.workflow_runs[] | select(.head_branch == env.tag_name) | .id' | head -n 1)
37+
38+
if [ -z "$run_id" ]; then
39+
echo "No run ID found for tag: $tag_name in workflow: $workflow_id"
40+
exit 1
41+
else
42+
echo "Found run ID: $run_id"
43+
echo "::set-output name=run_id::$run_id"
44+
fi
45+
46+
- name: Download artifacts
2947
uses: actions/download-artifact@v4
3048
with:
31-
pattern: firmware-*
32-
merge-multiple: true
49+
pattern: firmware-*
50+
merge-multiple: true
51+
run-id: ${{ steps.find_run_id.outputs.run_id }}
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
3353

3454
- name: Deploy release to github
3555
uses: softprops/action-gh-release@v2

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
secrets: inherit
3131
with:
3232
build_bl_update: true
33+
build_debug: true
34+
memfault_sw_type: "hello.nrfcloud.com"
3335
dfu_check:
3436
uses: ./.github/workflows/dfu_check.yml
3537
needs: build

0 commit comments

Comments
 (0)