Skip to content

Commit 5bec2f5

Browse files
Update release-go-task using parallelization
Introducing the use of a matrix, greatly improves time performances during the build making process, since each build task is performed simultaneously. To support this, a check has been added to avoid creating the same changelog more than once. The calculation of the checksums has also been modified. Previously, it was done three (3) times at different stages of the workflow. This is pointless, since the only checksums that matter are the ones calculated when the files are in their final form. For this reason, it is now only done once during the release creation.
1 parent a751e4e commit 5bec2f5

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

workflow-templates/release-go-task.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,28 @@ jobs:
1919
create-release-artifacts:
2020
runs-on: ubuntu-latest
2121

22+
strategy:
23+
matrix:
24+
os:
25+
- Windows_32bit
26+
- Windows_64bit
27+
- Linux_32bit
28+
- Linux_64bit
29+
- Linux_ARMv6
30+
- Linux_ARMv7
31+
- Linux_ARM64
32+
- macOS_64bit
33+
- macOS_ARM64
34+
2235
steps:
2336
- name: Checkout repository
2437
uses: actions/checkout@v3
2538
with:
2639
fetch-depth: 0
2740

2841
- name: Create changelog
42+
# Avoid creating the same changelog for each os
43+
if: matrix.os == 'Windows_32bit'
2944
uses: arduino/create-changelog@v1
3045
with:
3146
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -132,14 +147,10 @@ jobs:
132147
run: |
133148
gon "${{ env.GON_CONFIG_PATH }}"
134149
135-
- name: Re-package binary and output checksum
150+
- name: Re-package binary
136151
id: re-package
137152
working-directory: ${{ env.DIST_DIR }}
138-
# This step performs the following:
139-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
140-
# 2. Recalculate package checksum
141-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
142-
# (it cannot be done there because of workflow job parallelization)
153+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
143154
run: |
144155
# GitHub's upload/download-artifact actions don't preserve file permissions,
145156
# so we need to add execution permission back until the action is made to do this.
@@ -149,11 +160,9 @@ jobs:
149160
tar -czvf "$PACKAGE_FILENAME" \
150161
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
151162
-C ../../ LICENSE.txt
152-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
153163
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
154-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
155164
156-
- name: Upload artifacts
165+
- name: Upload artifact
157166
uses: actions/upload-artifact@v3
158167
with:
159168
if-no-files-found: error
@@ -171,15 +180,11 @@ jobs:
171180
name: ${{ env.ARTIFACT_NAME }}
172181
path: ${{ env.DIST_DIR }}
173182

174-
- name: Update checksum
183+
- name: Create checksum file
184+
working-directory: ${{ env.DIST_DIR}}
175185
run: |
176-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
177-
for checksum_line in "${checksum_lines[@]}"
178-
do
179-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
180-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
181-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
182-
done
186+
TAG="${GITHUB_REF/refs\/tags\//}"
187+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
183188
184189
- name: Identify Prerelease
185190
# This is a workaround while waiting for create-release action

0 commit comments

Comments
 (0)