Skip to content

Commit dfbf112

Browse files
Calculate checksums during release creation
Checksums of the output files where previously calculated during the initial creation of the artifacts, during the notarization process and, finally, at the release creation's step. The whole process has been simplified and checksums are now computed only during the creation of the release.
1 parent 488d6f1 commit dfbf112

File tree

4 files changed

+29
-44
lines changed

4 files changed

+29
-44
lines changed

.github/workflows/publish-go-nightly-task.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,10 @@ jobs:
140140
run: |
141141
gon "${{ env.GON_CONFIG_PATH }}"
142142
143-
- name: Re-package binary and output checksum
143+
- name: Re-package binary
144144
id: re-package
145145
working-directory: ${{ env.DIST_DIR }}
146-
# This step performs the following:
147-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
148-
# 2. Recalculate package checksum
149-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
150-
# (it cannot be done there because of workflow job parallelization)
146+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
151147
run: |
152148
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
153149
# so we need to add execution permission back until the action is made to do this.
@@ -157,11 +153,9 @@ jobs:
157153
tar -czvf "$PACKAGE_FILENAME" \
158154
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
159155
-C ../../ LICENSE.txt
160-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
161156
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
162-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
163157
164-
- name: Upload artifacts
158+
- name: Upload artifact
165159
uses: actions/upload-artifact@v3
166160
with:
167161
if-no-files-found: error
@@ -179,15 +173,11 @@ jobs:
179173
name: ${{ env.ARTIFACT_NAME }}
180174
path: ${{ env.DIST_DIR }}
181175

182-
- name: Update checksum
176+
- name: Output checksum
177+
working-directory: ${{ env.DIST_DIR}}
183178
run: |
184-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
185-
for checksum_line in "${checksum_lines[@]}"
186-
do
187-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
188-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
189-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
190-
done
179+
TAG="nightly-$(date -u +"%Y%m%d")"
180+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* >> ${TAG}-checksums.txt
191181
192182
- name: Upload release files on Arduino downloads servers
193183
uses: docker://plugins/s3

.github/workflows/publish-go-tester-task.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ on:
2424
repository_dispatch:
2525

2626
env:
27+
# As defined by the Taskfile's PROJECT_NAME variable
28+
PROJECT_NAME: arduino-cli
2729
# As defined by the Taskfile's DIST_DIR variable
2830
DIST_DIR: dist
2931
BUILDS_ARTIFACT: build-artifacts
@@ -135,6 +137,19 @@ jobs:
135137
name: ${{ env.BUILDS_ARTIFACT }}
136138
path: ${{ env.BUILDS_ARTIFACT }}
137139

140+
# Calculate checksums once
141+
- name: Output checksum
142+
if: matrix.artifact.name == 'checksums'
143+
working-directory: ${{ env.BUILDS_ARTIFACT}}
144+
run: |
145+
PACKAGE_NAME_PREFIX="test"
146+
if [ "${{ github.event_name }}" = "pull_request" ]; then
147+
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
148+
fi
149+
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
150+
TAG="${PACKAGE_NAME_PREFIX}git-snapshot"
151+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* >> ${TAG}-checksums.txt
152+
138153
- name: Upload individual build artifact
139154
uses: actions/upload-artifact@v3
140155
with:

.github/workflows/release-go-task.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,10 @@ jobs:
145145
run: |
146146
gon "${{ env.GON_CONFIG_PATH }}"
147147
148-
- name: Re-package binary and output checksum
148+
- name: Re-package binary
149149
id: re-package
150150
working-directory: ${{ env.DIST_DIR }}
151-
# This step performs the following:
152-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
153-
# 2. Recalculate package checksum
154-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
155-
# (it cannot be done there because of workflow job parallelization)
151+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
156152
run: |
157153
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
158154
# so we need to add execution permission back until the action is made to do this.
@@ -162,11 +158,9 @@ jobs:
162158
tar -czvf "$PACKAGE_FILENAME" \
163159
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
164160
-C ../../ LICENSE.txt
165-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
166161
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
167-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
168162
169-
- name: Upload artifacts
163+
- name: Upload artifact
170164
uses: actions/upload-artifact@v3
171165
with:
172166
if-no-files-found: error
@@ -184,15 +178,11 @@ jobs:
184178
name: ${{ env.ARTIFACT_NAME }}
185179
path: ${{ env.DIST_DIR }}
186180

187-
- name: Update checksum
181+
- name: Output checksum
182+
working-directory: ${{ env.DIST_DIR}}
188183
run: |
189-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
190-
for checksum_line in "${checksum_lines[@]}"
191-
do
192-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
193-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
194-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
195-
done
184+
TAG="${GITHUB_REF/refs\/tags\//}"
185+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* >> ${TAG}-checksums.txt
196186
197187
- name: Identify Prerelease
198188
# This is a workaround while waiting for create-release action

DistTasks.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ version: "3"
2020
vars:
2121
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
2222
GO_VERSION: "1.17.8"
23-
CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"
2423

2524
tasks:
2625
Windows_32bit:
@@ -35,7 +34,6 @@ tasks:
3534
-p "{{.BUILD_PLATFORM}}"
3635
3736
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
38-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
3937
4038
vars:
4139
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_386"
@@ -57,7 +55,6 @@ tasks:
5755
-p "{{.BUILD_PLATFORM}}"
5856
5957
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
60-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
6158
6259
vars:
6360
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_amd64"
@@ -79,7 +76,6 @@ tasks:
7976
-p "{{.BUILD_PLATFORM}}"
8077
8178
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
82-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
8379
8480
vars:
8581
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
@@ -101,7 +97,6 @@ tasks:
10197
-p "{{.BUILD_PLATFORM}}"
10298
10399
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
104-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
105100
106101
vars:
107102
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
@@ -123,7 +118,6 @@ tasks:
123118
-p "{{.BUILD_PLATFORM}}"
124119
125120
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
126-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
127121
128122
vars:
129123
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
@@ -145,7 +139,6 @@ tasks:
145139
-p "{{.BUILD_PLATFORM}}"
146140
147141
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
148-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
149142
150143
vars:
151144
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -195,7 +188,6 @@ tasks:
195188
-p "{{.BUILD_PLATFORM}}"
196189
197190
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
198-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
199191
200192
vars:
201193
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -217,7 +209,6 @@ tasks:
217209
-p "{{.BUILD_PLATFORM}}"
218210
219211
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
220-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
221212
222213
vars:
223214
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
@@ -252,7 +243,6 @@ tasks:
252243
-p "{{.BUILD_PLATFORM}}"
253244
254245
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
255-
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
256246
257247
vars:
258248
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"

0 commit comments

Comments
 (0)