Skip to content

Commit c4d39e3

Browse files
authored
[skip changelog] Sync "Release" workflow with template (#1395)
We have assembled a collection of reusable GitHub Actions workflows: https://github.com/arduino/tooling-project-assets These workflows will be used in the repositories of all Arduino tooling projects. Some minor improvements and standardizations have been made in the upstream "template" workflow, and those are introduced to this repository via this pull request. Notable: - Replace changelog file read, deprecated `actions/create-release`, and asset upload steps with the comprehensive `ncipollo/release-action` action
1 parent 2d88f11 commit c4d39e3

File tree

1 file changed

+58
-59
lines changed

1 file changed

+58
-59
lines changed

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

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
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-cli
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-cli/
11+
ARTIFACT_NAME: dist
212

313
on:
414
push:
@@ -10,8 +20,8 @@ jobs:
1020
runs-on: ubuntu-latest
1121

1222
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v1
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
1525
with:
1626
fetch-depth: 0
1727

@@ -21,9 +31,9 @@ jobs:
2131
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
2232
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
2333
case-insensitive-regex: true
24-
changelog-file-path: "dist/CHANGELOG.md"
34+
changelog-file-path: "${{ env.DIST_DIR }}/CHANGELOG.md"
2535

26-
- name: Install Taskfile
36+
- name: Install Task
2737
uses: arduino/setup-task@v1
2838
with:
2939
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -35,35 +45,46 @@ jobs:
3545
- name: Upload artifacts
3646
uses: actions/upload-artifact@v2
3747
with:
38-
name: dist
39-
path: dist
48+
if-no-files-found: error
49+
name: ${{ env.ARTIFACT_NAME }}
50+
path: ${{ env.DIST_DIR }}
4051

4152
notarize-macos:
4253
runs-on: macos-latest
4354
needs: create-release-artifacts
4455

4556
steps:
46-
- name: Checkout
57+
- name: Checkout repository
4758
uses: actions/checkout@v2
4859

4960
- name: Download artifacts
5061
uses: actions/download-artifact@v2
5162
with:
52-
name: dist
53-
# to ensure compatibility with v1
54-
path: dist
63+
name: ${{ env.ARTIFACT_NAME }}
64+
path: ${{ env.DIST_DIR }}
5565

5666
- name: Import Code-Signing Certificates
5767
env:
5868
KEYCHAIN: "sign.keychain"
5969
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
70+
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
6071
run: |
6172
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
62-
security create-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
73+
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
6374
security default-keychain -s "${{ env.KEYCHAIN }}"
64-
security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
65-
security import "${{ env.INSTALLER_CERT_MAC_PATH }}" -k "${{ env.KEYCHAIN }}" -f pkcs12 -A -T /usr/bin/codesign -P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
66-
security set-key-partition-list -S apple-tool:,apple: -s -k "${{ secrets.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
75+
security unlock-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
76+
security import \
77+
"${{ env.INSTALLER_CERT_MAC_PATH }}" \
78+
-k "${{ env.KEYCHAIN }}" \
79+
-f pkcs12 \
80+
-A \
81+
-T "/usr/bin/codesign" \
82+
-P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
83+
security set-key-partition-list \
84+
-S apple-tool:,apple: \
85+
-s \
86+
-k "${{ env.KEYCHAIN_PASSWORD }}" \
87+
"${{ env.KEYCHAIN }}"
6788
6889
- name: Install gon for code signing and app notarization
6990
run: |
@@ -82,46 +103,33 @@ jobs:
82103
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
83104
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
84105
run: |
85-
# GitHub's upload/download-artifact@v1 actions don't preserve file permissions,
86-
# so we need to add execution permission back until @v2 actions are released.
87-
chmod +x dist/arduino-cli_osx_darwin_amd64/arduino-cli
106+
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
107+
# so we need to add execution permission back until the action is made to do this.
108+
chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}
88109
TAG="${GITHUB_REF/refs\/tags\//}"
89-
tar -czvf "dist/arduino-cli_${TAG}_macOS_64bit.tar.gz" \
90-
-C dist/arduino-cli_osx_darwin_amd64/ arduino-cli \
110+
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
111+
-C ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/ ${{ env.PROJECT_NAME }} \
91112
-C ../../ LICENSE.txt
92-
CLI_CHECKSUM="$(shasum -a 256 "dist/arduino-cli_${TAG}_macOS_64bit.tar.gz" | cut -d " " -f 1)"
93-
perl -pi -w -e "s/.*arduino-cli_${TAG}_macOS_64bit.tar.gz/${CLI_CHECKSUM} arduino-cli_${TAG}_macOS_64bit.tar.gz/g;" dist/*-checksums.txt
113+
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1)"
114+
perl -pi -w -e "s/.*${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/${CHECKSUM} ${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz/g;" ${{ env.DIST_DIR }}/*-checksums.txt
94115
95116
- name: Upload artifacts
96117
uses: actions/upload-artifact@v2
97118
with:
98-
name: dist
99-
path: dist
119+
if-no-files-found: error
120+
name: ${{ env.ARTIFACT_NAME }}
121+
path: ${{ env.DIST_DIR }}
100122

101123
create-release:
102124
runs-on: ubuntu-latest
103125
needs: notarize-macos
104126

105127
steps:
106-
- name: Checkout
107-
uses: actions/checkout@v2
108-
109128
- name: Download artifact
110129
uses: actions/download-artifact@v2
111130
with:
112-
name: dist
113-
# to ensure compatibility with v1
114-
path: dist
115-
116-
- name: Read CHANGELOG
117-
id: changelog
118-
run: |
119-
body="$(cat dist/CHANGELOG.md)"
120-
body="${body//'%'/'%25'}"
121-
body="${body//$'\n'/'%0A'}"
122-
body="${body//$'\r'/'%0D'}"
123-
echo "$body"
124-
echo "::set-output name=BODY::$body"
131+
name: ${{ env.ARTIFACT_NAME }}
132+
path: ${{ env.DIST_DIR }}
125133

126134
- name: Identify Prerelease
127135
# This is a workaround while waiting for create-release action
@@ -132,32 +140,23 @@ jobs:
132140
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
133141
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
134142
135-
- name: Create Github Release
136-
id: create_release
137-
uses: actions/create-release@v1
138-
env:
139-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
- name: Create Github Release and upload artifacts
144+
uses: ncipollo/release-action@v1
140145
with:
141-
tag_name: ${{ github.ref }}
142-
release_name: ${{ github.ref }}
143-
body: ${{ steps.changelog.outputs.BODY }}
146+
token: ${{ secrets.GITHUB_TOKEN }}
147+
bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
144148
draft: false
145149
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
146-
147-
- name: Upload release files on Github
148-
uses: svenstaro/upload-release-action@v2
149-
with:
150-
repo_token: ${{ secrets.GITHUB_TOKEN }}
151-
file: dist/*
152-
tag: ${{ github.ref }}
153-
file_glob: true
150+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
151+
# (all the files we need are in the DIST_DIR root)
152+
artifacts: ${{ env.DIST_DIR }}/*
154153

155154
- name: Upload release files on Arduino downloads servers
156155
uses: docker://plugins/s3
157156
env:
158-
PLUGIN_SOURCE: "dist/*"
159-
PLUGIN_TARGET: "/arduino-cli/"
160-
PLUGIN_STRIP_PREFIX: "dist/"
157+
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
158+
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
159+
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
161160
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
162161
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
163162
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

0 commit comments

Comments
 (0)