Skip to content

Commit a03b2f5

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 009458a commit a03b2f5

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

.github/workflows/release-go-crosscompile-task.yml

+38-21
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
DIST_DIR: dist
99
# The project's folder on Arduino's download server for uploading builds
1010
AWS_PLUGIN_TARGET: /arduinoOTA/
11-
ARTIFACT_NAME: dist
11+
ARTIFACT_PREFIX: dist-
1212
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
1313
GO_VERSION: "1.17"
1414

@@ -23,16 +23,25 @@ jobs:
2323

2424
strategy:
2525
matrix:
26-
task:
27-
- Windows_32bit
28-
- Windows_64bit
29-
- Linux_32bit
30-
- Linux_64bit
31-
- Linux_ARMv6
32-
- Linux_ARMv7
33-
- Linux_ARM64
34-
- macOS_64bit
35-
- macOS_ARM64
26+
os:
27+
- task: Windows_32bit
28+
artifact-suffix: Windows_32bit
29+
- task: Windows_64bit
30+
artifact-suffix: Windows_64bit
31+
- task: Linux_32bit
32+
artifact-suffix: Linux_32bit
33+
- task: Linux_64bit
34+
artifact-suffix: Linux_64bit
35+
- task: Linux_ARMv6
36+
artifact-suffix: Linux_ARMv6
37+
- task: Linux_ARMv7
38+
artifact-suffix: Linux_ARMv7
39+
- task: Linux_ARM64
40+
artifact-suffix: Linux_ARM64
41+
- task: macOS_64bit
42+
artifact-suffix: macOS_64bit
43+
- task: macOS_ARM64
44+
artifact-suffix: macOS_ARM64
3645

3746
steps:
3847
- name: Checkout repository
@@ -42,7 +51,7 @@ jobs:
4251

4352
- name: Create changelog
4453
# Avoid creating the same changelog for each os
45-
if: matrix.task == 'Windows_32bit'
54+
if: matrix.os.task == 'Windows_32bit'
4655
uses: arduino/create-changelog@v1
4756
with:
4857
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -62,17 +71,17 @@ jobs:
6271
version: 3.x
6372

6473
- name: Build
65-
run: task dist:${{ matrix.task }}
74+
run: task dist:${{ matrix.os.task }}
6675

6776
- name: Upload artifacts
6877
uses: actions/upload-artifact@v4
6978
with:
7079
if-no-files-found: error
71-
name: ${{ env.ARTIFACT_NAME }}
80+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
7281
path: ${{ env.DIST_DIR }}
7382

7483
notarize-macos:
75-
name: Notarize ${{ matrix.build.folder-suffix }}
84+
name: Notarize ${{ matrix.build.artifact-suffix }}
7685
runs-on: macos-latest
7786
needs: create-release-artifacts
7887
outputs:
@@ -85,9 +94,11 @@ jobs:
8594
strategy:
8695
matrix:
8796
build:
88-
- folder-suffix: darwin_amd64
97+
- artifact-suffix: macOS_64bit
98+
folder-suffix: darwin_amd64
8999
package-suffix: "macOS_64bit.tar.gz"
90-
- folder-suffix: darwin_arm64
100+
- artifact-suffix: macOS_ARM64
101+
folder-suffix: darwin_arm64
91102
package-suffix: "macOS_ARM64.tar.gz"
92103

93104
steps:
@@ -104,9 +115,14 @@ jobs:
104115
- name: Download artifacts
105116
uses: actions/download-artifact@v4
106117
with:
107-
name: ${{ env.ARTIFACT_NAME }}
118+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
108119
path: ${{ env.DIST_DIR }}
109120

121+
- name: Remove non-notarized artifact
122+
uses: geekyeggo/delete-artifact@v5
123+
with:
124+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
125+
110126
- name: Import Code-Signing Certificates
111127
env:
112128
KEYCHAIN: "sign.keychain"
@@ -172,11 +188,11 @@ jobs:
172188
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
173189
tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}/"
174190
175-
- name: Upload artifact
191+
- name: Upload notarized artifact
176192
uses: actions/upload-artifact@v4
177193
with:
178194
if-no-files-found: error
179-
name: ${{ env.ARTIFACT_NAME }}
195+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
180196
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
181197

182198
create-release:
@@ -187,8 +203,9 @@ jobs:
187203
- name: Download artifact
188204
uses: actions/download-artifact@v4
189205
with:
190-
name: ${{ env.ARTIFACT_NAME }}
206+
merge-multiple: true
191207
path: ${{ env.DIST_DIR }}
208+
pattern: ${{ env.ARTIFACT_PREFIX }}*
192209

193210
- name: Create checksum file
194211
working-directory: ${{ env.DIST_DIR}}

0 commit comments

Comments
 (0)