Skip to content

Commit b2f212c

Browse files
authored
Sync release assets with templates (#105)
We have assembled a collection of reusable project assets: https://github.com/arduino/tooling-project-assets These assets will be used in the repositories of all Arduino tooling projects. Some improvements and standardizations have been made in the upstream "template" release assets, and those are introduced to this repository here. Notable: - Handle signed commits - Make changelog generation system work correctly for prereleases - Improve failure detection
1 parent 685578a commit b2f212c

File tree

3 files changed

+77
-52
lines changed

3 files changed

+77
-52
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
name: release
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-task.md
2+
name: Release
3+
4+
env:
5+
# As defined by the Taskfile's PROJECT_NAME variable
6+
PROJECT_NAME: arduino-fwuploader
7+
# As defined by the Taskfile's DIST_DIR variable
8+
DIST_DIR: dist
9+
# The project's folder on Arduino's download server for uploading builds
10+
AWS_PLUGIN_TARGET: /arduino-fwuploader/
11+
ARTIFACT_NAME: dist
12+
# See: https://github.com/actions/setup-go/tree/v2#readme
13+
GO_VERSION: ^1.16.2
214

315
on:
416
push:
@@ -10,66 +22,76 @@ jobs:
1022
runs-on: ubuntu-latest
1123

1224
steps:
13-
- name: Checkout
25+
- name: Checkout repository
1426
uses: actions/checkout@v2
1527
with:
1628
fetch-depth: 0
1729

1830
- name: Create changelog
1931
uses: arduino/create-changelog@v1
2032
with:
21-
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+$'
33+
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
2234
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
2335
case-insensitive-regex: true
24-
changelog-file-path: "dist/CHANGELOG.md"
36+
changelog-file-path: "${{ env.DIST_DIR }}/CHANGELOG.md"
2537

26-
- name: Install Taskfile
38+
- name: Install Go
39+
uses: actions/setup-go@v2
40+
with:
41+
go-version: ${{ env.GO_VERSION }}
42+
43+
- name: Install Task
2744
uses: arduino/setup-task@v1
2845
with:
2946
repo-token: ${{ secrets.GITHUB_TOKEN }}
3047
version: 3.x
3148

32-
- uses: actions/setup-go@v2
33-
with:
34-
go-version: "^1.16.2"
35-
3649
- name: Build
3750
run: task dist:all
3851

3952
- name: Upload artifacts
4053
uses: actions/upload-artifact@v2
4154
with:
42-
name: dist
43-
path: dist
55+
if-no-files-found: error
56+
name: ${{ env.ARTIFACT_NAME }}
57+
path: ${{ env.DIST_DIR }}
4458

4559
notarize-macos:
4660
runs-on: macos-latest
4761
needs: create-release-artifacts
4862

4963
steps:
50-
- name: Checkout
64+
- name: Checkout repository
5165
uses: actions/checkout@v2
5266

5367
- name: Download artifacts
5468
uses: actions/download-artifact@v2
5569
with:
56-
name: dist
57-
# to ensure compatibility with v1
58-
# https://github.com/actions/download-artifact#compatibility-between-v1-and-v2
59-
path: dist
70+
name: ${{ env.ARTIFACT_NAME }}
71+
path: ${{ env.DIST_DIR }}
6072

6173
- name: Import Code-Signing Certificates
6274
env:
6375
KEYCHAIN: "sign.keychain"
6476
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
6577
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
6678
run: |
67-
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }}
68-
security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
69-
security default-keychain -s ${{ env.KEYCHAIN }}
70-
security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
71-
security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
72-
security set-key-partition-list -S apple-tool:,apple: -s -k ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
79+
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
80+
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
81+
security default-keychain -s "${{ env.KEYCHAIN }}"
82+
security unlock-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
83+
security import \
84+
"${{ env.INSTALLER_CERT_MAC_PATH }}" \
85+
-k "${{ env.KEYCHAIN }}" \
86+
-f pkcs12 \
87+
-A \
88+
-T "/usr/bin/codesign" \
89+
-P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
90+
security set-key-partition-list \
91+
-S apple-tool:,apple: \
92+
-s \
93+
-k "${{ env.KEYCHAIN_PASSWORD }}" \
94+
"${{ env.KEYCHAIN }}"
7395
7496
- name: Install gon for code signing and app notarization
7597
run: |
@@ -83,22 +105,24 @@ jobs:
83105
run: |
84106
gon gon.config.hcl
85107
86-
- name: Re-package binary and update checksum
87-
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
108+
- name: Re-package binary
109+
# This step performs the following:
110+
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
88111
run: |
89112
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
90-
# so we need to add execution permission back.
91-
chmod +x dist/macos64/arduino-fwuploader
92-
TAG=${GITHUB_REF/refs\/tags\//}
93-
tar czf dist/arduino-fwuploader_${TAG}_macOS_64bit.tar.gz \
94-
LICENSE.txt \
95-
-C dist/macos64/ arduino-fwuploader
113+
# 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 }}
115+
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 }}
96119
97120
- name: Upload artifacts
98121
uses: actions/upload-artifact@v2
99122
with:
100-
name: dist
101-
path: dist
123+
if-no-files-found: error
124+
name: ${{ env.ARTIFACT_NAME }}
125+
path: ${{ env.DIST_DIR }}
102126

103127
create-release:
104128
runs-on: ubuntu-latest
@@ -111,10 +135,8 @@ jobs:
111135
- name: Download artifact
112136
uses: actions/download-artifact@v2
113137
with:
114-
name: dist
115-
# to ensure compatibility with v1
116-
# https://github.com/actions/download-artifact#compatibility-between-v1-and-v2
117-
path: dist
138+
name: ${{ env.ARTIFACT_NAME }}
139+
path: ${{ env.DIST_DIR }}
118140

119141
- name: Install Taskfile
120142
uses: arduino/setup-task@v1
@@ -134,23 +156,23 @@ jobs:
134156
run: |
135157
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
136158
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
137-
if [[ $(/tmp/semver get prerel ${GITHUB_REF/refs\/tags\//}) ]]; then echo "::set-output name=IS_PRE::true"; fi
159+
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
138160
139161
- name: Create Github Release and upload artifacts
140162
uses: ncipollo/release-action@v1
141163
with:
142164
token: ${{ secrets.GITHUB_TOKEN }}
143-
bodyFile: "dist/CHANGELOG.md"
165+
bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
144166
draft: false
145167
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
146-
artifacts: dist/arduino-fwuploader*,dist/package_index.json
168+
artifacts: ${{ env.DIST_DIR }}/arduino-fwuploader*,${{ env.DIST_DIR }}/package_index.json
147169

148170
- name: Upload release files on Arduino downloads servers
149171
uses: docker://plugins/s3
150172
env:
151-
PLUGIN_SOURCE: "dist/arduino-fwuploader*"
152-
PLUGIN_TARGET: "/arduino-fwuploader/"
153-
PLUGIN_STRIP_PREFIX: "dist/"
173+
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/arduino-fwuploader*"
174+
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
175+
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
154176
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
155177
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
156178
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Taskfile.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,21 @@ vars:
218218
echo $(cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
219219
# build vars
220220
COMMIT:
221-
sh: echo "$(git log -n 1 --format=%h)"
221+
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
222222
TIMESTAMP:
223223
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
224224
TIMESTAMP_SHORT:
225225
sh: echo "{{now | date "20060102"}}"
226226
TAG:
227-
sh: echo "`git tag --points-at=HEAD 2> /dev/null | head -n1`"
228-
VERSION: "{{ if .NIGHTLY }}nightly-{{ .TIMESTAMP_SHORT }}{{ else if .TAG }}{{ .TAG }}{{ else }}{{ .PACKAGE_NAME_PREFIX }}git-snapshot{{ end }}"
227+
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
228+
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
229+
CONFIGURATION_PACKAGE: github.com/arduino/arduino-fwuploader/version
229230
LDFLAGS: >
230231
-ldflags
231232
'
232-
-X github.com/arduino/arduino-fwuploader/version.versionString={{.VERSION}}
233-
-X github.com/arduino/arduino-fwuploader/version.commit={{ .COMMIT }}
234-
-X github.com/arduino/arduino-fwuploader/version.date={{.TIMESTAMP}}
233+
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}}
234+
-X {{.CONFIGURATION_PACKAGE}}.commit={{ .COMMIT }}
235+
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
235236
'
236237
# test vars
237238
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
@@ -240,9 +241,9 @@ vars:
240241
TEST_LDFLAGS: >
241242
-ldflags
242243
'
243-
-X github.com/arduino/arduino-fwuploader/version.versionString={{.TEST_VERSION}}
244-
-X github.com/arduino/arduino-fwuploader/version.commit={{.TEST_COMMIT}}
245-
-X github.com/arduino/arduino-fwuploader/version.date={{.TIMESTAMP}}
244+
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.TEST_VERSION}}
245+
-X {{.CONFIGURATION_PACKAGE}}.commit={{.TEST_COMMIT}}
246+
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
246247
'
247248
# check-lint vars
248249

gon.config.hcl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/gon.config.hcl
2+
# See: https://github.com/mitchellh/gon#configuration-file
13
source = ["dist/macos64/arduino-fwuploader"]
24
bundle_id = "cc.arduino.arduino-fwuploader"
35

@@ -8,5 +10,5 @@ sign {
810
# Ask Gon for zip output to force notarization process to take place.
911
# The CI will ignore the zip output, using the signed binary only.
1012
zip {
11-
output_path = "arduino-fwuploader.zip"
13+
output_path = "unused.zip"
1214
}

0 commit comments

Comments
 (0)