Skip to content

Commit 9e0db82

Browse files
authored
Don't upload multiple times to same artifact in release workflow (#39)
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 571cbd4 commit 9e0db82

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

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

+33-20
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: /arduino-fwuploader/plugins/
11-
ARTIFACT_NAME: dist
11+
ARTIFACT_PREFIX: dist-
1212

1313
on:
1414
push:
@@ -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]+.*$'
@@ -57,13 +66,13 @@ jobs:
5766
version: 3.x
5867

5968
- name: Build
60-
run: task dist:${{ matrix.task }}
69+
run: task dist:${{ matrix.os.task }}
6170

6271
- name: Upload artifacts
6372
uses: actions/upload-artifact@v4
6473
with:
6574
if-no-files-found: error
66-
name: ${{ env.ARTIFACT_NAME }}
75+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
6776
path: ${{ env.DIST_DIR }}
6877

6978
notarize-macos:
@@ -79,9 +88,11 @@ jobs:
7988
strategy:
8089
matrix:
8190
build:
82-
- folder-suffix: darwin_amd64
91+
- artifact-suffix: macOS_64bit
92+
folder-suffix: darwin_amd64
8393
package-suffix: "macOS_64bit.tar.gz"
84-
- folder-suffix: darwin_arm64
94+
- artifact-suffix: macOS_ARM64
95+
folder-suffix: darwin_arm64
8596
package-suffix: "macOS_ARM64.tar.gz"
8697

8798
steps:
@@ -98,7 +109,7 @@ jobs:
98109
- name: Download artifacts
99110
uses: actions/download-artifact@v4
100111
with:
101-
name: ${{ env.ARTIFACT_NAME }}
112+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
102113
path: ${{ env.DIST_DIR }}
103114

104115
- name: Import Code-Signing Certificates
@@ -166,11 +177,12 @@ jobs:
166177
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
167178
tar -czvf "${{ env.PACKAGE_FILENAME }}" "${{ env.BUILD_FOLDER }}"
168179
169-
- name: Upload artifact
180+
- name: Replace artifact with notarized build
170181
uses: actions/upload-artifact@v4
171182
with:
172183
if-no-files-found: error
173-
name: ${{ env.ARTIFACT_NAME }}
184+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
185+
overwrite: true
174186
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
175187

176188
create-release:
@@ -186,7 +198,8 @@ jobs:
186198
- name: Download artifact
187199
uses: actions/download-artifact@v4
188200
with:
189-
name: ${{ env.ARTIFACT_NAME }}
201+
pattern: ${{ env.ARTIFACT_PREFIX }}*
202+
merge-multiple: true
190203
path: ${{ env.DIST_DIR }}
191204

192205
- name: Install Taskfile

0 commit comments

Comments
 (0)