Skip to content

Commit 4d525dd

Browse files
committed
[skip changelog] Add release process
1 parent 54e1502 commit 4d525dd

File tree

4 files changed

+291
-0
lines changed

4 files changed

+291
-0
lines changed

.github/workflows/release.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
create-release-artifacts:
10+
runs-on: ubuntu-latest
11+
12+
container:
13+
image: arduino/arduino-cli:builder-1
14+
volumes:
15+
# cache go dependencies across pipeline's steps
16+
- ${{ github.workspace }}/go:/go
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v1
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Build
25+
run: goreleaser
26+
27+
- name: Upload artifacts
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: dist
31+
path: dist
32+
33+
notarize-macos:
34+
runs-on: macos-latest
35+
needs: create-release-artifacts
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
- name: Download artifacts
42+
uses: actions/download-artifact@v2
43+
with:
44+
name: dist
45+
# to ensure compatibility with v1
46+
path: dist
47+
48+
- name: Import Code-Signing Certificates
49+
env:
50+
KEYCHAIN: "sign.keychain"
51+
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
52+
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
53+
run: |
54+
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }}
55+
security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
56+
security default-keychain -s ${{ env.KEYCHAIN }}
57+
security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
58+
security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}
59+
security set-key-partition-list -S apple-tool:,apple: -s -k ${{ env.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
60+
61+
- name: Install gon for code signing and app notarization
62+
run: |
63+
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
64+
unzip gon_macos.zip -d /usr/local/bin
65+
66+
- name: Sign and notarize binary
67+
env:
68+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
69+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
70+
run: |
71+
gon gon.config.hcl
72+
73+
- name: Re-package binary and update checksum
74+
# This step performs the following:
75+
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
76+
# 2. Recalculate package checksum and replace it in the goreleaser nnnnnn-checksums.txt file
77+
run: |
78+
# GitHub's upload/download-artifact@v2 action doen't preserve file permissions,
79+
# so we need to add execution permission back until the action is made to do this.
80+
chmod +x dist/arduino_lint_osx_darwin_amd64/arduino-lint
81+
TAG=${GITHUB_REF/refs\/tags\//}
82+
tar -czvf dist/arduino-lint_${TAG}_macOS_64bit.tar.gz \
83+
-C dist/arduino_lint_osx_darwin_amd64/ arduino-lint \
84+
-C ../../ LICENSE.txt
85+
LINT_CHECKSUM=$(shasum -a 256 dist/arduino-lint_${TAG}_macOS_64bit.tar.gz | cut -d " " -f 1)
86+
perl -pi -w -e "s/.*arduino-lint_${TAG}_macOS_64bit.tar.gz/${LINT_CHECKSUM} arduino-lint_${TAG}_macOS_64bit.tar.gz/g;" dist/*-checksums.txt
87+
88+
- name: Upload artifacts
89+
uses: actions/upload-artifact@v2
90+
with:
91+
name: dist
92+
path: dist
93+
94+
create-release:
95+
runs-on: ubuntu-latest
96+
needs: notarize-macos
97+
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v2
101+
102+
- name: Download artifact
103+
uses: actions/download-artifact@v2
104+
with:
105+
name: dist
106+
# to ensure compatibility with v1
107+
path: dist
108+
109+
- name: Read CHANGELOG
110+
id: changelog
111+
run: |
112+
body=$(cat dist/CHANGELOG.md)
113+
body="${body//'%'/'%25'}"
114+
body="${body//$'\n'/'%0A'}"
115+
body="${body//$'\r'/'%0D'}"
116+
echo $body
117+
echo "::set-output name=BODY::$body"
118+
119+
- name: Identify Prerelease
120+
# This is a workaround while waiting for create-release action
121+
# to implement auto pre-release based on tag
122+
id: prerelease
123+
run: |
124+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
125+
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
126+
if [[ $(/tmp/semver get prerel ${GITHUB_REF/refs\/tags\//}) ]]; then echo "::set-output name=IS_PRE::true"; fi
127+
128+
- name: Create Github Release
129+
id: create_release
130+
uses: actions/create-release@v1
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
with:
134+
tag_name: ${{ github.ref }}
135+
release_name: ${{ github.ref }}
136+
body: ${{ steps.changelog.outputs.BODY }}
137+
draft: false
138+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
139+
140+
- name: Upload release files on Github
141+
uses: svenstaro/upload-release-action@v2
142+
with:
143+
repo_token: ${{ secrets.GITHUB_TOKEN }}
144+
file: dist/*
145+
tag: ${{ github.ref }}
146+
file_glob: true
147+
148+
- name: Upload release files on Arduino downloads servers
149+
uses: docker://plugins/s3
150+
env:
151+
PLUGIN_SOURCE: "dist/*"
152+
PLUGIN_TARGET: "/arduino-lint/"
153+
PLUGIN_STRIP_PREFIX: "dist/"
154+
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
155+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
156+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ coverage_unit.txt
1818
/docsgen/arduino-cli
1919
/docsgen/arduino-cli.exe
2020
/docs/commands/*.md
21+
22+
/dist

.goreleaser.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Global section
2+
checksum:
3+
name_template: '{{ .Tag }}-{{ time "20060102" }}-checksums.txt'
4+
5+
snapshot:
6+
name_template: '{{ .Env.PACKAGE_NAME_PREFIX }}-{{ time "20060102" }}'
7+
8+
release:
9+
disable: true
10+
11+
changelog:
12+
filters:
13+
exclude:
14+
# [skip changelog], [skip-changelog], [changelog skip], [changelog-skip]
15+
- '^(?i)\[(skip|changelog)[ ,-](skip|changelog)\].*'
16+
17+
# We have multiple builds in order to fine tune
18+
# cross compilations.
19+
builds:
20+
- # OSX
21+
id: arduino_lint_osx
22+
binary: arduino-lint
23+
env:
24+
- CGO_ENABLED=1
25+
- CXXFLAGS="-mmacosx-version-min=10.10"
26+
- CC=/usr/x86_64-apple-darwin14/bin/cc
27+
goos:
28+
- darwin
29+
goarch:
30+
- amd64
31+
ldflags:
32+
- -s -w
33+
- -X github.com/arduino/arduino-lint/configuration.version={{.Tag}}
34+
- -X github.com/arduino/arduino-lint/configuration.commit={{ .ShortCommit }}
35+
- -X github.com/arduino/arduino-lint/configuration.buildTimestamp={{.Date}}
36+
- # ARM
37+
id: arduino_lint_arm
38+
binary: arduino-lint
39+
env:
40+
- CGO_ENABLED=1
41+
- CC=/usr/arm-linux-gnueabi/bin/cc
42+
goos:
43+
- linux
44+
goarch:
45+
- arm
46+
goarm:
47+
- 6
48+
ldflags:
49+
- -s -w
50+
- -X github.com/arduino/arduino-lint/configuration.version={{.Tag}}
51+
- -X github.com/arduino/arduino-lint/configuration.commit={{ .ShortCommit }}
52+
- -X github.com/arduino/arduino-lint/configuration.buildTimestamp={{.Date}}
53+
- "-extldflags '-static'"
54+
- # ARMv7
55+
id: arduino_lint_armv7
56+
binary: arduino-lint
57+
env:
58+
- CGO_ENABLED=1
59+
- CC=/usr/arm-linux-gnueabihf/bin/cc
60+
goos:
61+
- linux
62+
goarch:
63+
- arm
64+
goarm:
65+
- 7
66+
ldflags:
67+
- -s -w
68+
- -X github.com/arduino/arduino-lint/configuration.version={{.Tag}}
69+
- -X github.com/arduino/arduino-lint/configuration.commit={{ .ShortCommit }}
70+
- -X github.com/arduino/arduino-lint/configuration.buildTimestamp={{.Date}}
71+
- "-extldflags '-static'"
72+
- # ARM64
73+
id: arduino_lint_arm64
74+
binary: arduino-lint
75+
env:
76+
- CGO_ENABLED=1
77+
- CC=/usr/aarch64-linux-gnu/bin/cc
78+
goos:
79+
- linux
80+
goarch:
81+
- arm64
82+
ldflags:
83+
- -s -w
84+
- -X github.com/arduino/arduino-lint/configuration.version={{.Tag}}
85+
- -X github.com/arduino/arduino-lint/configuration.commit={{ .ShortCommit }}
86+
- -X github.com/arduino/arduino-lint/configuration.buildTimestamp={{.Date}}
87+
- "-extldflags '-static'"
88+
- # All the other platforms
89+
id: arduino_lint
90+
binary: arduino-lint
91+
env:
92+
- CGO_ENABLED=0
93+
goos:
94+
- linux
95+
- windows
96+
goarch:
97+
- amd64
98+
- 386
99+
ldflags:
100+
- -s -w
101+
- -X github.com/arduino/arduino-lint/configuration.version={{.Tag}}
102+
- -X github.com/arduino/arduino-lint/configuration.commit={{ .ShortCommit }}
103+
- -X github.com/arduino/arduino-lint/configuration.buildTimestamp={{.Date}}
104+
- "-extldflags '-static'"
105+
106+
archives:
107+
- id: "arduino_lint"
108+
format: tar.gz
109+
format_overrides:
110+
- goos: windows
111+
format: zip
112+
replacements:
113+
amd64: 64bit
114+
darwin: macOS
115+
386: 32bit
116+
arm: ARM
117+
arm64: ARM64
118+
linux: Linux
119+
windows: Windows
120+
files:
121+
- LICENSE.txt

gon.config.hcl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
source = ["dist/arduino_lint_osx_darwin_amd64/arduino-lint"]
2+
bundle_id = "cc.arduino.arduino-lint"
3+
4+
sign {
5+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
6+
}
7+
8+
# Ask Gon for zip output to force notarization process to take place.
9+
# The CI will ignore the zip output, using the signed binary only.
10+
zip {
11+
output_path = "arduino-lint.zip"
12+
}

0 commit comments

Comments
 (0)