Skip to content

Commit f6bc34f

Browse files
committed
Change release workflow
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
1 parent 2eaab63 commit f6bc34f

5 files changed

Lines changed: 287 additions & 102 deletions

File tree

.github/actions/get-artifact-info/action.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ inputs:
88
description: 'Github token for requests to Github API'
99
required: false
1010
outputs:
11-
name:
12-
description: "The artifact name"
13-
value: ${{ steps.get-artifact.outputs.name }}
1411
exists:
1512
description: "True if the artifact was found, false otherwise"
1613
value: ${{ steps.get-artifact.outputs.exists }}

.github/workflows/qemu_build.yaml

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Qemu artifacts
1+
name: Get/Build Qemu artifacts
22

33
on:
44
workflow_call:
@@ -21,25 +21,19 @@ on:
2121
outputs:
2222
artifact_suffix:
2323
description: 'The suffix of the Qemu artifact (version-hash)'
24-
type: string
25-
value: ${{ jobs.build-Qemu.outputs.suffix }}
24+
value: ${{ jobs.summarize-info.outputs.suffix }}
2625
artifact_run_id:
2726
description: 'The run id that built the Qemu artifacts'
28-
type: string
29-
value: ${{ jobs.build-Qemu.outputs.run_id }}
27+
value: ${{ jobs.summarize-info.outputs.run_id }}
3028

3129
jobs:
32-
build-Qemu:
33-
name: Build Qemu static binaries
34-
strategy:
35-
matrix:
36-
arch: ${{ fromJSON(inputs.arch) }}
37-
runs-on: ${{ fromJSON(inputs.runner-arch-map)[matrix.arch] }}
30+
check-artifact-existence:
31+
runs-on: ubuntu-latest
3832
outputs:
39-
suffix: ${{ steps.artifact_info.outputs.suffix }}
40-
run_id: ${{ steps.artifact_info.outputs.run_id }}
33+
suffix: ${{ steps.name.outputs.suffix }}
34+
exists: ${{ steps.search.outputs.exists }}
35+
run_id: ${{ steps.search.outputs.run_id }}
4136
steps:
42-
4337
- name: Harden the runner (Audit all outbound calls)
4438
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
4539
with:
@@ -58,7 +52,66 @@ jobs:
5852
QEMU_IGNORE_LIST=$( sort qemu/unnecessary_files.txt )
5953
QEMU_FILES_HASH=$( echo $QEMU_AMD64_CONFIG $QEMU_ARM64_CONFIG $QEMU_IGNORE_LIST | md5sum | cut -d ' ' -f 1)
6054
echo "hash=${QEMU_FILES_HASH}" >> $GITHUB_OUTPUT
61-
echo "full=qemu-${{ matrix.arch }}-${{ inputs.qemu_version }}-${QEMU_FILES_HASH}" >> $GITHUB_OUTPUT
55+
echo "suffix=${{ inputs.qemu_version }}-${QEMU_FILES_HASH}" >> $GITHUB_OUTPUT
56+
echo "full=qemu-{0}-${{ inputs.qemu_version }}-${QEMU_FILES_HASH}" >> $GITHUB_OUTPUT
57+
58+
- name: Search for amd64 artifact
59+
id: search_amd64
60+
uses: ./.github/actions/get-artifact-info/
61+
with:
62+
name: format(${{ steps.name.outputs.full }}, 'amd64')
63+
token: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Search for armd64 artifact
66+
id: search_arm64
67+
uses: ./.github/actions/get-artifact-info/
68+
with:
69+
name: format(${{ steps.name.outputs.full }}, 'arm64')
70+
token: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Summarize search results
73+
id: search
74+
run: |
75+
if [[ ${{ steps.search_amd64.outputs.exists }} == 'false' ]] || \
76+
[[ ${{ steps.search_arm64.outputs.exists }} == 'false' ]]
77+
then
78+
echo "exists=false" >> $GITHUB_OUTPUT
79+
echo "run_id=" >> $GITHUB_OUTPUT
80+
echo "download_url=" >> $GITHUB_OUTPUT
81+
else
82+
if [[ ${{ steps.search_amd64.outputs.run_id }} != ${{ steps.search_arm64.outputs.run_id }} ]]
83+
then
84+
echo "exists=false" >> $GITHUB_OUTPUT
85+
echo "run_id=" >> $GITHUB_OUTPUT
86+
echo "download_url=" >> $GITHUB_OUTPUT
87+
else
88+
echo "exists=true" >> $GITHUB_OUTPUT
89+
echo "run_id=${{ steps.search_arm64.outputs.run_id }}" >> $GITHUB_OUTPUT
90+
echo "download_url=${{ steps.search_arm64.outputs.download_url }}" >> $GITHUB_OUTPUT
91+
fi
92+
fi
93+
94+
build-Qemu:
95+
name: Build Qemu static binaries
96+
needs: [check-artifact-existence]
97+
if: ${{ needs.check-artifact-existence.outputs.exists == 'false' }}
98+
strategy:
99+
matrix:
100+
arch: ${{ fromJSON(inputs.arch) }}
101+
runs-on: ${{ fromJSON(inputs.runner-arch-map)[matrix.arch] }}
102+
outputs:
103+
run_id: ${{ steps.artifact_info.outputs.run_id }}
104+
steps:
105+
106+
- name: Harden the runner (Audit all outbound calls)
107+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
108+
with:
109+
egress-policy: audit
110+
111+
- name: Checkout code
112+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
113+
with:
114+
fetch-depth: 0
62115

63116
- name: Install base dependencies
64117
run: |
@@ -86,11 +139,29 @@ jobs:
86139
- name: Archive Qemu artifacts
87140
uses: actions/upload-artifact@v4
88141
with:
89-
name: ${{ steps.name.outputs.full }}
142+
name: qemu-${{ matrix.arch }}-${{ needs.check-artifact-existence.outputs.suffix }}
90143
path: /tmp/qemu_build
91144

92145
- name: Collect artifact build info
93146
id: artifact_info
94147
run: |
148+
echo "${{ github.run_id }}"
95149
echo "run_id=${{ github.run_id }}" >> $GITHUB_OUTPUT
96-
echo "suffix=${{ inputs.qemu_version }}-${{ steps.name.outputs.hash }}" >> $GITHUB_OUTPUT
150+
151+
summarize-info:
152+
runs-on: ubuntu-latest
153+
needs: [check-artifact-existence, build-Qemu]
154+
if: ${{ !cancelled() }}
155+
outputs:
156+
suffix: ${{ needs.check-artifact-existence.outputs.suffix }}
157+
run_id: ${{ steps.info.outputs.run_id }}
158+
steps:
159+
- name: Produce correct artifact info
160+
id: info
161+
run: |
162+
if [[ "${{ needs.check-artifact-existence.outputs.exists }}" == "false" ]]
163+
then
164+
echo "run_id=${{ needs.build-Qemu.outputs.run_id }}" >> $GITHUB_OUTPUT
165+
else
166+
echo "run_id=${{ needs.check-artifact-existence.outputs.run_id }}" >> $GITHUB_OUTPUT
167+
fi

.github/workflows/release-trigger.yaml

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
echo "Tag: $TAG"
140140
echo "Commit: $COMMIT"
141141
142-
build-qemu-artifacts:
142+
build-Qemu-artifacts:
143143
name: Check and build missing Qemu artifacts
144144
needs: [get-versions,check-release-existance,tag-parent]
145145
if: needs.check-release-existance.outputs.exists == 'false'
@@ -149,7 +149,7 @@ jobs:
149149
arch: '["amd64", "arm64"]'
150150
secrets: inherit
151151

152-
build-solo5-artifacts:
152+
build-Solo5-artifacts:
153153
name: Check and build missing Solo5 artifacts
154154
needs: [get-versions,check-release-existance,tag-parent]
155155
if: needs.check-release-existance.outputs.exists == 'false'
@@ -159,7 +159,7 @@ jobs:
159159
arch: '["amd64", "arm64"]'
160160
secrets: inherit
161161

162-
build-Virtiofsd-artifact:
162+
build-Virtiofsd-artifacts:
163163
name: Check and build missing Virtiofsd artifact
164164
needs: [get-versions,check-release-existance,tag-parent]
165165
if: needs.check-release-existance.outputs.exists == 'false'
@@ -171,7 +171,7 @@ jobs:
171171

172172
create-new-release:
173173
name: Create new release
174-
needs: [get-versions,check-release-existance,build-qemu-artifacts,build-solo5-artifacts]
174+
needs: [get-versions,check-release-existance,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts]
175175
if: needs.check-release-existance.outputs.exists == 'false'
176176
runs-on: ubuntu-latest
177177
permissions:
@@ -183,108 +183,66 @@ jobs:
183183
with:
184184
egress-policy: audit
185185

186-
- name: Get Qemu artifact's workflow id
187-
id: qemu_artifact
188-
run: |
189-
RUN_ID=$(curl -s -H "Accept: application/vnd.github.v3+json" \
190-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
191-
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=success" \
192-
| jq -r '.workflow_runs[].artifacts_url' \
193-
| xargs -I {} curl -s -H "Accept: application/vnd.github.v3+json" \
194-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
195-
{} \
196-
| jq -r --arg TARGET \
197-
"qemu-amd64-${{ needs.get-versions.outputs.qemu_version }}-${{ needs.check-release-existance.outputs.qemu_hash }}" \
198-
'.artifacts[]? | select(.name == $TARGET) | .workflow_run.id' \
199-
| head -n 1)
200-
201-
echo "runID=${RUN_ID}" >> $GITHUB_OUTPUT
202-
203-
- name: Get Solo5 artifact's workflow id
204-
id: solo5_artifact
205-
run: |
206-
RUN_ID=$(curl -s -H "Accept: application/vnd.github.v3+json" \
207-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
208-
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=success" \
209-
| jq -r '.workflow_runs[].artifacts_url' \
210-
| xargs -I {} curl -s -H "Accept: application/vnd.github.v3+json" \
211-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
212-
{} \
213-
| jq -r --arg TARGET \
214-
"solo5-hvt-amd64-${{ needs.get-versions.outputs.solo5_version }}" \
215-
'.artifacts[]? | select(.name == $TARGET) | .workflow_run.id' \
216-
| head -n 1)
217-
218-
echo "runID=${RUN_ID}" >> $GITHUB_OUTPUT
219-
220-
- name: Get Virtiofsd artifact's workflow id
221-
id: virtiofsd_artifact
186+
- name: Download Firecracker amd64 binary
222187
run: |
223-
RUN_ID=$(curl -s -H "Accept: application/vnd.github.v3+json" \
224-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
225-
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=success" \
226-
| jq -r '.workflow_runs[].artifacts_url' \
227-
| xargs -I {} curl -s -H "Accept: application/vnd.github.v3+json" \
228-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
229-
{} \
230-
| jq -r --arg TARGET \
231-
"virtiofsd-amd64-${{ needs.get-versions.outputs.virtiofsd_version }}" \
232-
'.artifacts[]? | select(.name == $TARGET) | .workflow_run.id' \
233-
| head -n 1)
234-
235-
echo "runID=${RUN_ID}" >> $GITHUB_OUTPUT
188+
echo "Qemu Run id is ${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}
189+
echo "Qemu suffix is ${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}
190+
echo "Solo5 Run id is ${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}
191+
echo "Solo5 suffix is ${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}
192+
echo "Virtiofsd Run id is ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}
193+
echo "Virtiofsd suffix is ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}
236194
237195
- name: Download Qemu amd64 artifacts
238196
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
239197
with:
240-
name: qemu-amd64-${{ needs.get-versions.outputs.qemu_version }}-${{ needs.check-release-existance.outputs.qemu_hash }}
198+
name: qemu-amd64-${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}
241199
path: /tmp/qemu_amd64
242-
run-id: ${{ steps.qemu_artifact.outputs.runID }}
200+
run-id: ${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}
243201
merge-multiple: true
244202
github-token: ${{ secrets.GITHUB_TOKEN }}
245203

246204
- name: Download Qemu arm64 artifacts
247205
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
248206
with:
249-
name: qemu-arm64-${{ needs.get-versions.outputs.qemu_version }}-${{ needs.check-release-existance.outputs.qemu_hash }}
207+
name: qemu-arm64-${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}
250208
path: /tmp/qemu_arm64
251-
run-id: ${{ steps.qemu_artifact.outputs.runID }}
209+
run-id: ${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}
252210
merge-multiple: true
253211
github-token: ${{ secrets.GITHUB_TOKEN }}
254212

255213
- name: Download Solo5 amd64 artifacts
256214
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
257215
with:
258-
pattern: solo5-*-amd64-${{ needs.get-versions.outputs.solo5_version }}
216+
pattern: solo5-*-amd64-${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}
259217
path: /tmp/solo5_amd64
260-
run-id: ${{ steps.solo5_artifact.outputs.runID }}
218+
run-id: ${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}
261219
merge-multiple: true
262220
github-token: ${{ secrets.GITHUB_TOKEN }}
263221

264222
- name: Download Solo5 arm64 artifacts
265223
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
266224
with:
267-
pattern: solo5-*-arm64-${{ needs.get-versions.outputs.solo5_version }}
225+
pattern: solo5-*-arm64-${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}
268226
path: /tmp/solo5_arm64
269-
run-id: ${{ steps.solo5_artifact.outputs.runID }}
227+
run-id: ${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}
270228
merge-multiple: true
271229
github-token: ${{ secrets.GITHUB_TOKEN }}
272230

273231
- name: Download Virtiofsd amd64 artifacts
274232
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
275233
with:
276-
name: virtiofsd-amd64-${{ needs.get-versions.outputs.virtiofsd_version }}
234+
name: virtiofsd-amd64-${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}
277235
path: /tmp/virtiofsd_amd64
278-
run-id: ${{ steps.virtiofsd_artifact.outputs.runID }}
236+
run-id: ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}
279237
merge-multiple: true
280238
github-token: ${{ secrets.GITHUB_TOKEN }}
281239

282240
- name: Download Virtiofsd arm64 artifacts
283241
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
284242
with:
285-
name: virtiofsd-arm64-${{ needs.get-versions.outputs.virtiofsd_version }}
243+
name: virtiofsd-arm64-${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}
286244
path: /tmp/virtiofsd_arm64
287-
run-id: ${{ steps.virtiofsd_artifact.outputs.runID }}
245+
run-id: ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}
288246
merge-multiple: true
289247
github-token: ${{ secrets.GITHUB_TOKEN }}
290248

0 commit comments

Comments
 (0)