Skip to content

Commit 1b806ac

Browse files
committed
Don't upload multiple times to same artifact in "Release" workflow
The "Release" GitHub Actions workflow generates binaries for a range of target hosts. This is done by using a job matrix that produces each build in a parallel job. GitHub Actions workflow artifacts are used to transfer the generated files between sequential jobs in the workflow. The "actions/upload-artifact" and "actions/download-artifact" actions are used for this purpose. Previously, a single artifact was used for this purpose, with each of the parallel jobs uploading its own generated files to that artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0 of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the builds. These can be downloaded in aggregate by using the artifact name globbing and merging features which were introduced in version 4.1.0 of the "actions/download-artifact" action.
1 parent 6986b5c commit 1b806ac

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ env:
44
# The name of the project
55
PROJECT_NAME: imgtool
66
DIST_DIR: dist
7-
ARTIFACT_NAME: dist
7+
ARTIFACT_PREFIX: dist-
88
# The project's folder on Arduino's download server for uploading builds
99
AWS_PLUGIN_TARGET: /tools/
1010
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
@@ -112,7 +112,7 @@ jobs:
112112
uses: actions/upload-artifact@v4
113113
with:
114114
if-no-files-found: error
115-
name: ${{ env.ARTIFACT_NAME }}
115+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.package_platform }}
116116
path: ${{ env.MCUBOOT_PATH }}/scripts/dist/${{ env.PROJECT_NAME }}_*
117117

118118
build-crosscompile:
@@ -183,23 +183,31 @@ jobs:
183183
uses: actions/upload-artifact@v4
184184
with:
185185
if-no-files-found: error
186-
name: ${{ env.ARTIFACT_NAME }}
186+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.package_platform }}
187187
path: ${{ env.MCUBOOT_PATH }}/scripts/dist/${{ env.PROJECT_NAME }}_*
188188

189189
notarize-macos:
190190
runs-on: macos-latest
191191
needs: build
192192

193+
env:
194+
ARTIFACT_SUFFIX: macOS_64bit
195+
193196
steps:
194197
- name: Checkout repository
195198
uses: actions/checkout@v4
196199

197-
- name: Download artifacts
200+
- name: Download non-notarized artifact
198201
uses: actions/download-artifact@v4
199202
with:
200-
name: ${{ env.ARTIFACT_NAME }}
203+
name: ${{ env.ARTIFACT_PREFIX }}${{ env.ARTIFACT_SUFFIX }}
201204
path: ${{ env.DIST_DIR }}
202205

206+
- name: Remove non-notarized artifact
207+
uses: geekyeggo/delete-artifact@v5
208+
with:
209+
name: ${{ env.ARTIFACT_PREFIX }}${{ env.ARTIFACT_SUFFIX }}
210+
203211
- name: Import Code-Signing Certificates
204212
env:
205213
KEYCHAIN: "sign.keychain"
@@ -248,11 +256,11 @@ jobs:
248256
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz"
249257
tar -czvf "${PACKAGE_FILENAME}" "${{ env.PROJECT_NAME }}_macOS_64bit"
250258
251-
- name: Upload artifacts
259+
- name: Upload notarized artifact
252260
uses: actions/upload-artifact@v4
253261
with:
254262
if-no-files-found: error
255-
name: ${{ env.ARTIFACT_NAME }}
263+
name: ${{ env.ARTIFACT_PREFIX }}${{ env.ARTIFACT_SUFFIX }}
256264
path: ${{ env.DIST_DIR }}
257265

258266
create-release:
@@ -266,8 +274,9 @@ jobs:
266274
- name: Download artifact
267275
uses: actions/download-artifact@v4
268276
with:
269-
name: ${{ env.ARTIFACT_NAME }}
277+
merge-multiple: true
270278
path: ${{ env.DIST_DIR }}
279+
pattern: ${{ env.ARTIFACT_PREFIX }}*
271280

272281
- name: Identify Prerelease
273282
# This is a workaround while waiting for create-release action

0 commit comments

Comments
 (0)