Skip to content

Commit 4fa043e

Browse files
committed
Don't upload multiple times to same artifact in release workflow
The release workflow produces binaries for a range of target hosts. This is done by using a job matrix in the GitHub Actions workflow 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" action is 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 72c2235 commit 4fa043e

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

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

Lines changed: 33 additions & 20 deletions
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: /discovery/mdns-discovery/
11-
ARTIFACT_NAME: dist
11+
ARTIFACT_PREFIX: dist-
1212

1313
on:
1414
push:
@@ -21,16 +21,25 @@ jobs:
2121

2222
strategy:
2323
matrix:
24-
task:
25-
- Windows_32bit
26-
- Windows_64bit
27-
- Linux_32bit
28-
- Linux_64bit
29-
- Linux_ARMv6
30-
- Linux_ARMv7
31-
- Linux_ARM64
32-
- macOS_64bit
33-
- macOS_ARM64
24+
os:
25+
- task: Windows_32bit
26+
artifact-suffix: Windows_32bit
27+
- task: Windows_64bit
28+
artifact-suffix: Windows_64bit
29+
- task: Linux_32bit
30+
artifact-suffix: Linux_32bit
31+
- task: Linux_64bit
32+
artifact-suffix: Linux_64bit
33+
- task: Linux_ARMv6
34+
artifact-suffix: Linux_ARMv6
35+
- task: Linux_ARMv7
36+
artifact-suffix: Linux_ARMv7
37+
- task: Linux_ARM64
38+
artifact-suffix: Linux_ARM64
39+
- task: macOS_64bit
40+
artifact-suffix: macOS_64bit
41+
- task: macOS_ARM64
42+
artifact-suffix: macOS_ARM64
3443

3544
steps:
3645
- name: Checkout repository
@@ -40,7 +49,7 @@ jobs:
4049

4150
- name: Create changelog
4251
# Avoid creating the same changelog for each os
43-
if: matrix.task == 'Windows_32bit'
52+
if: matrix.os.task == 'Windows_32bit'
4453
uses: arduino/create-changelog@v1
4554
with:
4655
tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -55,13 +64,13 @@ jobs:
5564
version: 3.x
5665

5766
- name: Build
58-
run: task dist:${{ matrix.task }}
67+
run: task dist:${{ matrix.os.task }}
5968

6069
- name: Upload artifacts
6170
uses: actions/upload-artifact@v4
6271
with:
6372
if-no-files-found: error
64-
name: ${{ env.ARTIFACT_NAME }}
73+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
6574
path: ${{ env.DIST_DIR }}
6675

6776
notarize-macos:
@@ -75,9 +84,11 @@ jobs:
7584
strategy:
7685
matrix:
7786
build:
78-
- folder-suffix: darwin_amd64
87+
- artifact-suffix: macOS_64bit
88+
folder-suffix: darwin_amd64
7989
package-suffix: "macOS_64bit.tar.gz"
80-
- folder-suffix: darwin_arm64
90+
- artifact-suffix: macOS_ARM64
91+
folder-suffix: darwin_arm64
8192
package-suffix: "macOS_ARM64.tar.gz"
8293

8394
steps:
@@ -94,7 +105,7 @@ jobs:
94105
- name: Download artifacts
95106
uses: actions/download-artifact@v4
96107
with:
97-
name: ${{ env.ARTIFACT_NAME }}
108+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
98109
path: ${{ env.DIST_DIR }}
99110

100111
- name: Import Code-Signing Certificates
@@ -164,11 +175,12 @@ jobs:
164175
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
165176
tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}"
166177
167-
- name: Upload artifact
178+
- name: Replace artifact with notarized build
168179
uses: actions/upload-artifact@v4
169180
with:
170181
if-no-files-found: error
171-
name: ${{ env.ARTIFACT_NAME }}
182+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
183+
overwrite: true
172184
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
173185

174186
create-release:
@@ -179,7 +191,8 @@ jobs:
179191
- name: Download artifact
180192
uses: actions/download-artifact@v4
181193
with:
182-
name: ${{ env.ARTIFACT_NAME }}
194+
pattern: ${{ env.ARTIFACT_PREFIX }}*
195+
merge-multiple: true
183196
path: ${{ env.DIST_DIR }}
184197

185198
- name: Create checksum file

0 commit comments

Comments
 (0)