Skip to content

Commit 56e0a14

Browse files
committed
Use more meaningful variable names in release workflows
The project's templates include GitHub Actions workflows are used to automatically generate beta tester and production builds of Go-based projects. 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 2621fbb commit 56e0a14

File tree

4 files changed

+93
-75
lines changed

4 files changed

+93
-75
lines changed

workflow-templates/publish-go-nightly-task.yml

Lines changed: 34 additions & 25 deletions
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: TODO_AWS_PLUGIN_TARGET
1111
AWS_REGION: "us-east-1"
12-
ARTIFACT_NAME: dist
12+
ARTIFACT_PREFIX: dist-
1313

1414
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1515
on:
@@ -28,15 +28,24 @@ jobs:
2828
strategy:
2929
matrix:
3030
os:
31-
- Windows_32bit
32-
- Windows_64bit
33-
- Linux_32bit
34-
- Linux_64bit
35-
- Linux_ARMv6
36-
- Linux_ARMv7
37-
- Linux_ARM64
38-
- macOS_64bit
39-
- macOS_ARM64
31+
- task: Windows_32bit
32+
artifact-suffix: Windows_32bit
33+
- task: Windows_64bit
34+
artifact-suffix: Windows_64bit
35+
- task: Linux_32bit
36+
artifact-suffix: Linux_32bit
37+
- task: Linux_64bit
38+
artifact-suffix: Linux_64bit
39+
- task: Linux_ARMv6
40+
artifact-suffix: Linux_ARMv6
41+
- task: Linux_ARMv7
42+
artifact-suffix: Linux_ARMv7
43+
- task: Linux_ARM64
44+
artifact-suffix: Linux_ARM64
45+
- task: macOS_64bit
46+
artifact-suffix: macOS_64bit
47+
- task: macOS_ARM64
48+
artifact-suffix: macOS_ARM64
4049

4150
steps:
4251
- name: Checkout repository
@@ -51,17 +60,17 @@ jobs:
5160
- name: Build
5261
env:
5362
NIGHTLY: true
54-
run: task dist:${{ matrix.os }}
63+
run: task dist:${{ matrix.os.task }}
5564

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

6372
notarize-macos:
64-
name: Notarize ${{ matrix.artifact.name }}
73+
name: Notarize ${{ matrix.build.folder-suffix }}
6574
runs-on: macos-latest
6675
needs: create-nightly-artifacts
6776

@@ -77,11 +86,11 @@ jobs:
7786

7887
strategy:
7988
matrix:
80-
artifact:
81-
- name: darwin_amd64
82-
path: "macOS_64bit.tar.gz"
83-
- name: darwin_arm64
84-
path: "macOS_ARM64.tar.gz"
89+
build:
90+
- folder-suffix: darwin_amd64
91+
package-suffix: "macOS_64bit.tar.gz"
92+
- folder-suffix: darwin_arm64
93+
package-suffix: "macOS_ARM64.tar.gz"
8594

8695
steps:
8796
- name: Checkout repository
@@ -90,7 +99,7 @@ jobs:
9099
- name: Download artifacts
91100
uses: actions/download-artifact@v4
92101
with:
93-
pattern: ${{ env.ARTIFACT_NAME }}-*
102+
pattern: ${{ env.ARTIFACT_PREFIX }}*
94103
merge-multiple: true
95104
path: ${{ env.DIST_DIR }}
96105

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

175184
publish-nightly:
@@ -183,7 +192,7 @@ jobs:
183192
- name: Download artifact
184193
uses: actions/download-artifact@v4
185194
with:
186-
pattern: ${{ env.ARTIFACT_NAME }}-*
195+
pattern: ${{ env.ARTIFACT_PREFIX }}*
187196
merge-multiple: true
188197
path: ${{ env.DIST_DIR }}
189198

workflow-templates/publish-go-tester-task.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
7878
build:
7979
needs: package-name-prefix
80-
name: Build ${{ matrix.os.name }}
80+
name: Build ${{ matrix.os.artifact-name }}
8181
runs-on: ubuntu-latest
8282
permissions:
8383
contents: read
@@ -87,31 +87,31 @@ jobs:
8787
os:
8888
- task: Windows_32bit
8989
path: "*Windows_32bit.zip"
90-
name: Windows_X86-32
90+
artifact-name: Windows_X86-32
9191
- task: Windows_64bit
9292
path: "*Windows_64bit.zip"
93-
name: Windows_X86-64
93+
artifact-name: Windows_X86-64
9494
- task: Linux_32bit
9595
path: "*Linux_32bit.tar.gz"
96-
name: Linux_X86-32
96+
artifact-name: Linux_X86-32
9797
- task: Linux_64bit
9898
path: "*Linux_64bit.tar.gz"
99-
name: Linux_X86-64
99+
artifact-name: Linux_X86-64
100100
- task: Linux_ARMv6
101101
path: "*Linux_ARMv6.tar.gz"
102-
name: Linux_ARMv6
102+
artifact-name: Linux_ARMv6
103103
- task: Linux_ARMv7
104104
path: "*Linux_ARMv7.tar.gz"
105-
name: Linux_ARMv7
105+
artifact-name: Linux_ARMv7
106106
- task: Linux_ARM64
107107
path: "*Linux_ARM64.tar.gz"
108-
name: Linux_ARM64
108+
artifact-name: Linux_ARM64
109109
- task: macOS_64bit
110110
path: "*macOS_64bit.tar.gz"
111-
name: macOS_64
111+
artifact-name: macOS_64
112112
- task: macOS_ARM64
113113
path: "*macOS_ARM64.tar.gz"
114-
name: macOS_ARM64
114+
artifact-name: macOS_ARM64
115115

116116
steps:
117117
- name: Checkout repository
@@ -134,7 +134,7 @@ jobs:
134134
uses: actions/upload-artifact@v4
135135
with:
136136
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
137-
name: ${{ matrix.os.name }}
137+
name: ${{ matrix.os.artifact-name }}
138138

139139
checksums:
140140
needs:

workflow-templates/release-go-crosscompile-task.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
strategy:
2828
matrix:
29-
os:
29+
task:
3030
- Windows_32bit
3131
- Windows_64bit
3232
- Linux_32bit
@@ -45,7 +45,7 @@ jobs:
4545

4646
- name: Create changelog
4747
# Avoid creating the same changelog for each os
48-
if: matrix.os == 'Windows_32bit'
48+
if: matrix.task == 'Windows_32bit'
4949
uses: arduino/create-changelog@v1
5050
with:
5151
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -65,7 +65,7 @@ jobs:
6565
version: 3.x
6666

6767
- name: Build
68-
run: task dist:${{ matrix.os }}
68+
run: task dist:${{ matrix.task }}
6969

7070
- name: Upload artifacts
7171
uses: actions/upload-artifact@v3
@@ -75,7 +75,7 @@ jobs:
7575
path: ${{ env.DIST_DIR }}
7676

7777
notarize-macos:
78-
name: Notarize ${{ matrix.artifact.name }}
78+
name: Notarize ${{ matrix.build.folder-suffix }}
7979
runs-on: macos-latest
8080
needs: create-release-artifacts
8181
permissions:
@@ -86,11 +86,11 @@ jobs:
8686

8787
strategy:
8888
matrix:
89-
artifact:
90-
- name: darwin_amd64
91-
path: "macOS_64bit.tar.gz"
92-
- name: darwin_arm64
93-
path: "macOS_ARM64.tar.gz"
89+
build:
90+
- folder-suffix: darwin_amd64
91+
package-suffix: "macOS_64bit.tar.gz"
92+
- folder-suffix: darwin_arm64
93+
package-suffix: "macOS_ARM64.tar.gz"
9494

9595
steps:
9696
- name: Checkout repository
@@ -136,7 +136,7 @@ jobs:
136136
run: |
137137
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
138138
# See: https://github.com/Bearer/gon#configuration-file
139-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
139+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
140140
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
141141
142142
sign {
@@ -165,11 +165,11 @@ jobs:
165165
run: |
166166
# GitHub's upload/download-artifact actions don't preserve file permissions,
167167
# so we need to add execution permission back until the action is made to do this.
168-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
168+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
169169
TAG="${GITHUB_REF/refs\/tags\//}"
170-
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
170+
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
171171
tar -czvf "$PACKAGE_FILENAME" \
172-
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
172+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/" "${{ env.PROJECT_NAME }}" \
173173
-C ../../ LICENSE.txt
174174
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
175175

0 commit comments

Comments
 (0)