Skip to content

Commit b506f9b

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 f0ecaac commit b506f9b

File tree

4 files changed

+29
-44
lines changed

4 files changed

+29
-44
lines changed

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

+7-17
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,19 @@ jobs:
146146
run: |
147147
gon "${{ env.GON_CONFIG_PATH }}"
148148
149-
- name: Re-package binary and output checksum
149+
- name: Re-package binary
150150
id: re-package
151151
working-directory: ${{ env.DIST_DIR }}
152-
# This step performs the following:
153-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
154-
# 2. Recalculate package checksum
155-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
156-
# (it cannot be done there because of workflow job parallelization)
152+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
157153
run: |
158154
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
159155
# so we need to add execution permission back until the action is made to do this.
160156
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
161157
tar -czvf "${{ env.PACKAGE_FILENAME }}" \
162158
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
163159
-C ../../ LICENSE.txt
164-
CHECKSUM_LINE="$(shasum -a 256 ${{ env.PACKAGE_FILENAME }})"
165-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
166160
167-
- name: Upload artifacts
161+
- name: Upload artifact
168162
uses: actions/upload-artifact@v3
169163
with:
170164
if-no-files-found: error
@@ -182,15 +176,11 @@ jobs:
182176
name: ${{ env.ARTIFACT_NAME }}
183177
path: ${{ env.DIST_DIR }}
184178

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

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

+15
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:

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

+7-17
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,19 @@ jobs:
151151
run: |
152152
gon "${{ env.GON_CONFIG_PATH }}"
153153
154-
- name: Re-package binary and output checksum
154+
- name: Re-package binary
155155
id: re-package
156156
working-directory: ${{ env.DIST_DIR }}
157-
# This step performs the following:
158-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
159-
# 2. Recalculate package checksum
160-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
161-
# (it cannot be done there because of workflow job parallelization)
157+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
162158
run: |
163159
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
164160
# so we need to add execution permission back until the action is made to do this.
165161
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
166162
tar -czvf "${{ env.PACKAGE_FILENAME }}" \
167163
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
168164
-C ../../ LICENSE.txt
169-
CHECKSUM_LINE="$(shasum -a 256 ${{ env.PACKAGE_FILENAME }}"
170-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
171165
172-
- name: Upload artifacts
166+
- name: Upload artifact
173167
uses: actions/upload-artifact@v3
174168
with:
175169
if-no-files-found: error
@@ -187,15 +181,11 @@ jobs:
187181
name: ${{ env.ARTIFACT_NAME }}
188182
path: ${{ env.DIST_DIR }}
189183

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

Diff for: DistTasks.yml

-10
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)