Skip to content

Commit 8e0dc93

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 bee321e commit 8e0dc93

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

Diff for: .github/workflows/release-go-crosscompile-task.yml

+38-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
# The project's folder on Arduino's download server for uploading builds
1010
AWS_PLUGIN_TARGET: /arduino-fwuploader/
1111
AWS_REGION: "us-east-1"
12-
ARTIFACT_NAME: dist
12+
ARTIFACT_PREFIX: dist-
1313
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
1414
GO_VERSION: "1.18"
1515

@@ -26,16 +26,25 @@ jobs:
2626

2727
strategy:
2828
matrix:
29-
task:
30-
- Windows_32bit
31-
- Windows_64bit
32-
- Linux_32bit
33-
- Linux_64bit
34-
- Linux_ARMv6
35-
- Linux_ARMv7
36-
- Linux_ARM64
37-
- macOS_64bit
38-
- macOS_ARM64
29+
os:
30+
- task: Windows_32bit
31+
artifact-suffix: Windows_32bit
32+
- task: Windows_64bit
33+
artifact-suffix: Windows_64bit
34+
- task: Linux_32bit
35+
artifact-suffix: Linux_32bit
36+
- task: Linux_64bit
37+
artifact-suffix: Linux_64bit
38+
- task: Linux_ARMv6
39+
artifact-suffix: Linux_ARMv6
40+
- task: Linux_ARMv7
41+
artifact-suffix: Linux_ARMv7
42+
- task: Linux_ARM64
43+
artifact-suffix: Linux_ARM64
44+
- task: macOS_64bit
45+
artifact-suffix: macOS_64bit
46+
- task: macOS_ARM64
47+
artifact-suffix: macOS_ARM64
3948

4049
steps:
4150
- name: Checkout repository
@@ -45,7 +54,7 @@ jobs:
4554

4655
- name: Create changelog
4756
# Avoid creating the same changelog for each os
48-
if: matrix.task == 'Windows_32bit'
57+
if: matrix.os.task == 'Windows_32bit'
4958
uses: arduino/create-changelog@v1
5059
with:
5160
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -65,17 +74,17 @@ jobs:
6574
version: 3.x
6675

6776
- name: Build
68-
run: task dist:${{ matrix.task }}
77+
run: task dist:${{ matrix.os.task }}
6978

7079
- name: Upload artifacts
7180
uses: actions/upload-artifact@v4
7281
with:
7382
if-no-files-found: error
74-
name: ${{ env.ARTIFACT_NAME }}
83+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
7584
path: ${{ env.DIST_DIR }}
7685

7786
notarize-macos:
78-
name: Notarize ${{ matrix.build.folder-suffix }}
87+
name: Notarize ${{ matrix.build.artifact-suffix }}
7988
runs-on: macos-latest
8089
needs: create-release-artifacts
8190
permissions:
@@ -87,9 +96,11 @@ jobs:
8796
strategy:
8897
matrix:
8998
build:
90-
- folder-suffix: darwin_amd64
99+
- artifact-suffix: macOS_64bit
100+
folder-suffix: darwin_amd64
91101
package-suffix: "macOS_64bit.tar.gz"
92-
- folder-suffix: darwin_arm64
102+
- artifact-suffix: macOS_ARM64
103+
folder-suffix: darwin_arm64
93104
package-suffix: "macOS_ARM64.tar.gz"
94105

95106
steps:
@@ -106,9 +117,14 @@ jobs:
106117
- name: Download artifacts
107118
uses: actions/download-artifact@v4
108119
with:
109-
name: ${{ env.ARTIFACT_NAME }}
120+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
110121
path: ${{ env.DIST_DIR }}
111122

123+
- name: Remove non-notarized artifact
124+
uses: geekyeggo/delete-artifact@v5
125+
with:
126+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
127+
112128
- name: Import Code-Signing Certificates
113129
env:
114130
KEYCHAIN: "sign.keychain"
@@ -177,11 +193,11 @@ jobs:
177193
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
178194
-C ../../ LICENSE.txt
179195
180-
- name: Upload artifact
196+
- name: Upload notarized artifact
181197
uses: actions/upload-artifact@v4
182198
with:
183199
if-no-files-found: error
184-
name: ${{ env.ARTIFACT_NAME }}
200+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
185201
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
186202

187203
create-release:
@@ -199,8 +215,9 @@ jobs:
199215
- name: Download artifact
200216
uses: actions/download-artifact@v4
201217
with:
202-
name: ${{ env.ARTIFACT_NAME }}
218+
merge-multiple: true
203219
path: ${{ env.DIST_DIR }}
220+
pattern: ${{ env.ARTIFACT_PREFIX }}*
204221

205222
- name: Install Taskfile
206223
uses: arduino/setup-task@v1

0 commit comments

Comments
 (0)