Skip to content

Commit 553d0b5

Browse files
committed
Use more meaningful variable names in release workflows
GitHub Actions workflows are used to automatically generate beta tester and production builds of the project. A separate build is generated for each of the target host types. This is done using a job matrix, which creates a parallel run of the workflow job for each target. The matrix defines variables that provide the data that is specific to each job. The variable names used previously did not clearly communicate their nature: - The variable for the task name was named "os" - The variables for the build filename components used the term "artifact", which is ambiguous in this context where the term is otherwise used to refer to the completely unrelated workflow artifacts These variable names made it very difficult for anyone not intimately familiar with the workings of the workflow to understand its code.
1 parent 34e0d05 commit 553d0b5

File tree

3 files changed

+80
-62
lines changed

3 files changed

+80
-62
lines changed

Diff for: .github/workflows/publish-go-nightly-task.yml

+34-25
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-lint/
11-
ARTIFACT_NAME: dist
11+
ARTIFACT_PREFIX: dist-
1212

1313
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1414
on:
@@ -27,15 +27,24 @@ jobs:
2727
strategy:
2828
matrix:
2929
os:
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
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
@@ -50,17 +59,17 @@ jobs:
5059
- name: Build
5160
env:
5261
NIGHTLY: true
53-
run: task dist:${{ matrix.os }}
62+
run: task dist:${{ matrix.os.task }}
5463

5564
- name: Upload artifacts
5665
uses: actions/upload-artifact@v4
5766
with:
5867
if-no-files-found: error
59-
name: ${{ env.ARTIFACT_NAME }}-${{ matrix.os }}
68+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
6069
path: ${{ env.DIST_DIR }}
6170

6271
notarize-macos:
63-
name: Notarize ${{ matrix.artifact.name }}
72+
name: Notarize ${{ matrix.build.folder-suffix }}
6473
runs-on: macos-latest
6574
needs: create-nightly-artifacts
6675

@@ -76,11 +85,11 @@ jobs:
7685

7786
strategy:
7887
matrix:
79-
artifact:
80-
- name: darwin_amd64
81-
path: "macOS_64bit.tar.gz"
82-
- name: darwin_arm64
83-
path: "macOS_ARM64.tar.gz"
88+
build:
89+
- folder-suffix: darwin_amd64
90+
package-suffix: "macOS_64bit.tar.gz"
91+
- folder-suffix: darwin_arm64
92+
package-suffix: "macOS_ARM64.tar.gz"
8493

8594
steps:
8695
- name: Checkout repository
@@ -89,7 +98,7 @@ jobs:
8998
- name: Download artifacts
9099
uses: actions/download-artifact@v4
91100
with:
92-
pattern: ${{ env.ARTIFACT_NAME }}-*
101+
pattern: ${{ env.ARTIFACT_PREFIX }}*
93102
merge-multiple: true
94103
path: ${{ env.DIST_DIR }}
95104

@@ -126,7 +135,7 @@ jobs:
126135
run: |
127136
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
128137
# See: https://github.com/Bearer/gon#configuration-file
129-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
138+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
130139
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
131140
132141
sign {
@@ -155,19 +164,19 @@ jobs:
155164
run: |
156165
# GitHub's upload/download-artifact actions don't preserve file permissions,
157166
# so we need to add execution permission back until the action is made to do this.
158-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
167+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
159168
# Use of an array here is required for globbing
160-
PACKAGE_FILENAME=(${{ env.PROJECT_NAME }}_nightly-*${{ matrix.artifact.path }})
169+
PACKAGE_FILENAME=(${{ env.PROJECT_NAME }}_nightly-*${{ matrix.build.package-suffix }})
161170
tar -czvf "$PACKAGE_FILENAME" \
162-
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
171+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/" "${{ env.PROJECT_NAME }}" \
163172
-C ../../ LICENSE.txt
164173
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
165174
166175
- name: Upload artifact
167176
uses: actions/upload-artifact@v4
168177
with:
169178
if-no-files-found: error
170-
name: ${{ env.ARTIFACT_NAME }}-notarized-${{ matrix.artifact.name }}
179+
name: ${{ env.ARTIFACT_PREFIX }}notarized-${{ matrix.build.folder-suffix }}
171180
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
172181

173182
publish-nightly:
@@ -179,7 +188,7 @@ jobs:
179188
- name: Download artifact
180189
uses: actions/download-artifact@v4
181190
with:
182-
pattern: ${{ env.ARTIFACT_NAME }}-*
191+
pattern: ${{ env.ARTIFACT_PREFIX }}*
183192
merge-multiple: true
184193
path: ${{ env.DIST_DIR }}
185194

Diff for: .github/workflows/publish-go-tester-task.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
7676
build:
7777
needs: package-name-prefix
78-
name: Build ${{ matrix.os.name }}
78+
name: Build ${{ matrix.os.artifact-name }}
7979
runs-on: ubuntu-latest
8080
permissions:
8181
contents: read
@@ -85,31 +85,31 @@ jobs:
8585
os:
8686
- task: Windows_32bit
8787
path: "*Windows_32bit.zip"
88-
name: Windows_X86-32
88+
artifact-name: Windows_X86-32
8989
- task: Windows_64bit
9090
path: "*Windows_64bit.zip"
91-
name: Windows_X86-64
91+
artifact-name: Windows_X86-64
9292
- task: Linux_32bit
9393
path: "*Linux_32bit.tar.gz"
94-
name: Linux_X86-32
94+
artifact-name: Linux_X86-32
9595
- task: Linux_64bit
9696
path: "*Linux_64bit.tar.gz"
97-
name: Linux_X86-64
97+
artifact-name: Linux_X86-64
9898
- task: Linux_ARMv6
9999
path: "*Linux_ARMv6.tar.gz"
100-
name: Linux_ARMv6
100+
artifact-name: Linux_ARMv6
101101
- task: Linux_ARMv7
102102
path: "*Linux_ARMv7.tar.gz"
103-
name: Linux_ARMv7
103+
artifact-name: Linux_ARMv7
104104
- task: Linux_ARM64
105105
path: "*Linux_ARM64.tar.gz"
106-
name: Linux_ARM64
106+
artifact-name: Linux_ARM64
107107
- task: macOS_64bit
108108
path: "*macOS_64bit.tar.gz"
109-
name: macOS_64
109+
artifact-name: macOS_64
110110
- task: macOS_ARM64
111111
path: "*macOS_ARM64.tar.gz"
112-
name: macOS_ARM64
112+
artifact-name: macOS_ARM64
113113

114114
steps:
115115
- name: Checkout repository
@@ -132,7 +132,7 @@ jobs:
132132
uses: actions/upload-artifact@v4
133133
with:
134134
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
135-
name: ${{ matrix.os.name }}
135+
name: ${{ matrix.os.artifact-name }}
136136

137137
checksums:
138138
needs:

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

+35-26
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-lint/
11-
ARTIFACT_NAME: dist
11+
ARTIFACT_PREFIX: dist-
1212

1313
on:
1414
push:
@@ -24,15 +24,24 @@ jobs:
2424
strategy:
2525
matrix:
2626
os:
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
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.os == '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,17 +66,17 @@ jobs:
5766
version: 3.x
5867

5968
- name: Build
60-
run: task dist:${{ matrix.os }}
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 }}-${{ matrix.os }}
75+
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
6776
path: ${{ env.DIST_DIR }}
6877

6978
notarize-macos:
70-
name: Notarize ${{ matrix.artifact.name }}
79+
name: Notarize ${{ matrix.build.folder-suffix }}
7180
runs-on: macos-latest
7281
needs: create-release-artifacts
7382
outputs:
@@ -81,11 +90,11 @@ jobs:
8190

8291
strategy:
8392
matrix:
84-
artifact:
85-
- name: darwin_amd64
86-
path: "macOS_64bit.tar.gz"
87-
- name: darwin_arm64
88-
path: "macOS_ARM64.tar.gz"
93+
build:
94+
- folder-suffix: darwin_amd64
95+
package-suffix: "macOS_64bit.tar.gz"
96+
- folder-suffix: darwin_arm64
97+
package-suffix: "macOS_ARM64.tar.gz"
8998

9099
steps:
91100
- name: Checkout repository
@@ -94,7 +103,7 @@ jobs:
94103
- name: Download artifacts
95104
uses: actions/download-artifact@v4
96105
with:
97-
pattern: ${{ env.ARTIFACT_NAME }}-*
106+
pattern: ${{ env.ARTIFACT_PREFIX }}*
98107
merge-multiple: true
99108
path: ${{ env.DIST_DIR }}
100109

@@ -131,7 +140,7 @@ jobs:
131140
run: |
132141
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
133142
# See: https://github.com/Bearer/gon#configuration-file
134-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
143+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
135144
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
136145
137146
sign {
@@ -160,19 +169,19 @@ jobs:
160169
run: |
161170
# GitHub's upload/download-artifact actions don't preserve file permissions,
162171
# so we need to add execution permission back until the action is made to do this.
163-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
172+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
164173
TAG="${GITHUB_REF/refs\/tags\//}"
165-
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
174+
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
166175
tar -czvf "$PACKAGE_FILENAME" \
167-
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
176+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/" "${{ env.PROJECT_NAME }}" \
168177
-C ../../ LICENSE.txt
169178
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
170179
171180
- name: Upload artifact
172181
uses: actions/upload-artifact@v4
173182
with:
174183
if-no-files-found: error
175-
name: ${{ env.ARTIFACT_NAME }}-notarized-${{ matrix.artifact.name }}
184+
name: ${{ env.ARTIFACT_PREFIX }}notarized-${{ matrix.build.folder-suffix }}
176185
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
177186

178187
create-release:
@@ -185,7 +194,7 @@ jobs:
185194
- name: Download artifact
186195
uses: actions/download-artifact@v4
187196
with:
188-
pattern: ${{ env.ARTIFACT_NAME }}-*
197+
pattern: ${{ env.ARTIFACT_PREFIX }}*
189198
merge-multiple: true
190199
path: ${{ env.DIST_DIR }}
191200

0 commit comments

Comments
 (0)