Skip to content

Commit f3ee9a7

Browse files
committed
uniform release-go-crosscompile-task to the assets repo:
- add macos arm64 - differentiate linux arm into linux armv6, and linux armv7 - bump version of GO to 1.17 - bump upload/artifact action from 2 to 3 - add checksum upload - remove unnecessary line continuation escaping from workflow - rename workflow - remove `gon.config.hcl` since now is hardcoded in the workflow
1 parent 0b157a1 commit f3ee9a7

File tree

2 files changed

+72
-31
lines changed

2 files changed

+72
-31
lines changed

.github/workflows/release-go-task.yml renamed to .github/workflows/release-go-crosscompile-task.yml

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-task.md
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-crosscompile-task.md
22
name: Release
33

44
env:
@@ -9,8 +9,8 @@ env:
99
# The project's folder on Arduino's download server for uploading builds
1010
AWS_PLUGIN_TARGET: /arduino-fwuploader/
1111
ARTIFACT_NAME: dist
12-
# See: https://github.com/actions/setup-go/tree/v2#readme
13-
GO_VERSION: ^1.16.2
12+
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
13+
GO_VERSION: "1.17"
1414

1515
on:
1616
push:
@@ -50,15 +50,30 @@ jobs:
5050
run: task dist:all
5151

5252
- name: Upload artifacts
53-
uses: actions/upload-artifact@v2
53+
uses: actions/upload-artifact@v3
5454
with:
5555
if-no-files-found: error
5656
name: ${{ env.ARTIFACT_NAME }}
5757
path: ${{ env.DIST_DIR }}
5858

5959
notarize-macos:
60+
name: Notarize ${{ matrix.artifact.name }}
6061
runs-on: macos-latest
6162
needs: create-release-artifacts
63+
outputs:
64+
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
65+
checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}
66+
67+
env:
68+
GON_CONFIG_PATH: gon.config.hcl
69+
70+
strategy:
71+
matrix:
72+
artifact:
73+
- name: darwin_amd64
74+
path: "macOS_64bit.tar.gz"
75+
- name: darwin_arm64
76+
path: "macOS_ARM64.tar.gz"
6277

6378
steps:
6479
- name: Checkout repository
@@ -98,38 +113,66 @@ jobs:
98113
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
99114
unzip gon_macos.zip -d /usr/local/bin
100115
116+
- name: Write gon config to file
117+
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
118+
run: |
119+
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
120+
# See: https://github.com/mitchellh/gon#configuration-file
121+
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
122+
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
123+
124+
sign {
125+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
126+
}
127+
128+
# Ask Gon for zip output to force notarization process to take place.
129+
# The CI will ignore the zip output, using the signed binary only.
130+
zip {
131+
output_path = "unused.zip"
132+
}
133+
EOF
134+
101135
- name: Sign and notarize binary
102136
env:
103137
AC_USERNAME: ${{ secrets.AC_USERNAME }}
104138
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
105139
run: |
106-
gon gon.config.hcl
140+
gon "${{ env.GON_CONFIG_PATH }}"
107141
108-
- name: Re-package binary
142+
- name: Re-package binary and output checksum
143+
id: re-package
144+
working-directory: ${{ env.DIST_DIR }}
109145
# This step performs the following:
110146
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
147+
# 2. Recalculate package checksum
148+
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
149+
# (it cannot be done there because of workflow job parallelization)
111150
run: |
112-
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
151+
# GitHub's upload/download-artifact actions don't preserve file permissions,
113152
# so we need to add execution permission back until the action is made to do this.
114-
chmod +x ${{ env.DIST_DIR }}/macos64/${{ env.PROJECT_NAME }}
153+
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
115154
TAG="${GITHUB_REF/refs\/tags\//}"
116-
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
117-
LICENSE.txt \
118-
-C ${{ env.DIST_DIR }}/macos64/ ${{ env.PROJECT_NAME }}
155+
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
156+
tar -czvf "$PACKAGE_FILENAME" \
157+
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
158+
-C ../../ LICENSE.txt
159+
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
160+
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
161+
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
119162
120163
- name: Upload artifacts
121-
uses: actions/upload-artifact@v2
164+
uses: actions/upload-artifact@v3
122165
with:
123166
if-no-files-found: error
124167
name: ${{ env.ARTIFACT_NAME }}
125-
path: ${{ env.DIST_DIR }}
168+
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}
126169

127170
create-release:
128171
runs-on: ubuntu-latest
129172
needs: notarize-macos
130173

131174
steps:
132-
- name: Checkout
175+
- name: Checkout # we need package_index.template
133176
uses: actions/checkout@v3
134177

135178
- name: Download artifact
@@ -149,13 +192,23 @@ jobs:
149192
# would be calculated since the binary is modified during notarization
150193
run: task dist:generate-index-data
151194

195+
- name: Update checksum
196+
run: |
197+
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
198+
for checksum_line in "${checksum_lines[@]}"
199+
do
200+
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
201+
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
202+
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
203+
done
204+
152205
- name: Identify Prerelease
153206
# This is a workaround while waiting for create-release action
154207
# to implement auto pre-release based on tag
155208
id: prerelease
156209
run: |
157-
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
158-
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
210+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
211+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
159212
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
160213
161214
- name: Create Github Release and upload artifacts
@@ -165,7 +218,9 @@ jobs:
165218
bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
166219
draft: false
167220
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
168-
artifacts: ${{ env.DIST_DIR }}/arduino-fwuploader*,${{ env.DIST_DIR }}/package_index.json
221+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
222+
# (all the files we need are in the DIST_DIR root)
223+
artifacts: ${{ env.DIST_DIR }}/*
169224

170225
- name: Upload release files on Arduino downloads servers
171226
uses: docker://plugins/s3

gon.config.hcl

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)