Skip to content

Commit 39c3b60

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 39c3b60

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

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)