Skip to content

Commit a423c20

Browse files
committed
port required files to make a release
1 parent 318de37 commit a423c20

File tree

5 files changed

+526
-1
lines changed

5 files changed

+526
-1
lines changed

.github/workflows/release.yml

+396
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,396 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
# The build job is responsible for: configuring the environment, testing and compiling process
10+
build:
11+
strategy:
12+
matrix:
13+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
14+
15+
runs-on: ${{ matrix.operating-system }}
16+
17+
steps:
18+
- name: Disable EOL conversions
19+
run: git config --global core.autocrlf false
20+
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
- name: Install Go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: "1.15"
28+
29+
# dependencies used for compiling the GUI
30+
- name: Install Dependencies (Linux)
31+
run: sudo apt update && sudo apt install -y --no-install-recommends build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev
32+
if: matrix.operating-system == 'ubuntu-latest'
33+
34+
- name: Install Go deps
35+
# Since 10/23/2019 pwsh is the default shell
36+
# on Windows, but pwsh fails to install protoc-gen-go so
37+
# we force bash as default shell for all OSes in this task
38+
run: |
39+
go get github.com/golangci/govet
40+
go get golang.org/x/lint/golint
41+
shell: bash
42+
43+
- name: Install Taskfile
44+
uses: arduino/actions/setup-taskfile@master
45+
with:
46+
version: '3.x'
47+
repo-token: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Check the code is good
50+
run: task check
51+
52+
- name: Run unit tests
53+
run: task test-unit
54+
55+
- name: Build the Agent
56+
run: task build
57+
if: matrix.operating-system != 'windows-latest'
58+
59+
# build the agent without GUI support (no tray icon)
60+
- name: Build the Agent-cli
61+
run: task build-cli
62+
if: matrix.operating-system == 'ubuntu-latest'
63+
64+
# the manifest is required by windows GUI apps, otherwise the binary will crash with: "Unable to create main window: TTM_ADDTOOL failed" (for reference https://github.com/lxn/walk/issues/28)
65+
# rsrc will produce *.syso files that should get automatically recognized by go build command and linked into an executable.
66+
- name: Embed manifest in win binary
67+
run: |
68+
go get github.com/akavel/rsrc
69+
rsrc -arch 386 -manifest manifest.xml
70+
if: matrix.operating-system == 'windows-latest'
71+
72+
# building the agent for win requires a different task because of an extra flag
73+
- name: Build the Agent for win32
74+
env:
75+
GOARCH: 386 # 32bit architecture (for support)
76+
GO386: 387 # support old instruction sets without MMX (used in the Pentium 4) (will be deprecated in GO > 1.15 https://golang.org/doc/go1.15)
77+
run: task build-win32
78+
if: matrix.operating-system == 'windows-latest'
79+
80+
# config.ini is required by the executable when it's run
81+
- name: Upload artifacts
82+
uses: actions/upload-artifact@v2
83+
with:
84+
name: arduino-create-agent-${{ matrix.operating-system }}
85+
path: |
86+
arduino-create-agent*
87+
config.ini
88+
if-no-files-found: error
89+
90+
# The code-sign-mac-executable job will download the macos artifact from the previous job, sign e notarize the binary and re-upload it.
91+
code-sign-mac-executable:
92+
needs: build
93+
runs-on: macos-latest
94+
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v2
98+
with:
99+
repository: 'bcmi-labs/arduino-create-agent-installer' # the repo which contains gon.config.hcl
100+
token: ${{ secrets.ARDUINO_CREATE_AGENT_CI_PAT }}
101+
102+
- name: Download artifact
103+
uses: actions/download-artifact@v2
104+
with:
105+
name: arduino-create-agent-macos-latest
106+
path: arduino-create-agent-macos-latest
107+
108+
- name: Import Code-Signing Certificates
109+
env:
110+
KEYCHAIN: "sign.keychain"
111+
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
112+
run: |
113+
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }}
114+
security create-keychain -p ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
115+
security default-keychain -s ${{ env.KEYCHAIN }}
116+
security unlock-keychain -p ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
117+
security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}
118+
security set-key-partition-list -S apple-tool:,apple: -s -k ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
119+
120+
- name: Install gon for code signing and app notarization
121+
run: |
122+
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
123+
unzip gon_macos.zip -d /usr/local/bin
124+
125+
- name: Code sign and notarize app
126+
env:
127+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
128+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
129+
run: |
130+
gon -log-level=debug -log-json gon.config.hcl
131+
# gon will notarize executable in "arduino-create-agent-macos-latest/arduino-create-agent
132+
# The CI will ignore the zip output, using the signed binary only.
133+
timeout-minutes: 30
134+
135+
# This step will overwrite the non signed mac artifact (arduino-create-agent-macos-latest)
136+
- name: Upload artifact
137+
uses: actions/upload-artifact@v2
138+
with:
139+
name: arduino-create-agent-macos-latest
140+
path: arduino-create-agent-macos-latest
141+
if-no-files-found: error
142+
143+
# This job is responsible for generating the installers (using installbuilder)
144+
package:
145+
needs: code-sign-mac-executable
146+
runs-on: ubuntu-latest
147+
148+
env:
149+
# vars used by installbuilder
150+
INSTALLBUILDER_PATH: "/opt/installbuilder-20.9.0/bin/builder"
151+
# INSTALLER_VARS: "project.outputDirectory=$PWD project.version=${GITHUB_REF##*/} workspace=$PWD realname=Arduino_Create_Bridge"
152+
# vars passed to installbuilder to install https certs automatically
153+
CERT_INSTALL: "ask_certificates_install=CI" # win(edge),mac(safari)
154+
NO_CERT_INSTALL: "ask_certificates_install=CS" # linux
155+
CHOICE_CERT_INSTALL: "ask_certificates_install=CC" # win,mac:(ff,chrome)
156+
CREATE_OSX_BUNDLED_MG: 0 # tell installbuilder to not create the DMG, gon will take care of that later
157+
# installbuilder will read this vars automatically (defined in installer.xml):
158+
INSTALLER_CERT_WINDOWS_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
159+
INSTALLER_CERT_WINDOWS_PFX: "/tmp/ArduinoCerts2020.pfx"
160+
INSTALLER_CERT_MAC_PASSWORD: ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}
161+
INSTALLER_CERT_MAC_P12: "/tmp/ArduinoCerts2020.p12"
162+
163+
strategy:
164+
fail-fast: false # if one os is failing continue nonetheless
165+
matrix: # used to generate installers for different OS and not for runs-on
166+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
167+
168+
include:
169+
- operating-system: ubuntu-latest
170+
install-builder-name: linux-x64
171+
executable-path: artifacts/linux-amd64/
172+
- operating-system: windows-latest
173+
browser: edge
174+
install-builder-name: windows
175+
executable-path: artifacts/windows/
176+
extension: .exe
177+
installer-extension: .exe
178+
- operating-system: macos-latest
179+
browser: safari
180+
install-builder-name: osx
181+
executable-path: 'skel/ArduinoCreateAgent.app/Contents/MacOS/'
182+
installer-extension: .app
183+
184+
container:
185+
image: floydpink/ubuntu-install-builder:20.9.0
186+
187+
steps:
188+
189+
# workaround to strip bugfix number from semver (only to make 1.1 release) I will change this in the future
190+
- name: Set version env vars
191+
# VERSION will be available only in the next step
192+
run: |
193+
echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
194+
195+
- name: Set installer env vars
196+
run: |
197+
echo INSTALLER_VARS="project.outputDirectory=$PWD project.version=${VERSION%.*} workspace=$PWD realname=Arduino_Create_Bridge" >> $GITHUB_ENV
198+
199+
- name: Checkout
200+
uses: actions/checkout@v2
201+
with:
202+
repository: 'bcmi-labs/arduino-create-agent-installer' # the repo which contains install.xml
203+
token: ${{ secrets.ARDUINO_CREATE_AGENT_CI_PAT }}
204+
205+
- name: Download artifact
206+
uses: actions/download-artifact@v2
207+
with:
208+
name: arduino-create-agent-${{ matrix.operating-system }}
209+
path: ${{ matrix.executable-path }} # path expected by installbuilder
210+
211+
# zip artifacts do not mantain executable permission
212+
- name: Make executable
213+
run: chmod -v +x ${{ matrix.executable-path }}arduino-create-agent*
214+
if: matrix.operating-system == 'ubuntu-latest' || matrix.operating-system == 'macos-latest'
215+
216+
- name: Rename executable to Arduino_Create_Bridge
217+
run: mv -v ${{ matrix.executable-path }}arduino-create-agent${{ matrix.extension }} ${{ matrix.executable-path }}Arduino_Create_Bridge${{ matrix.extension }}
218+
219+
- name: Rename executable to Arduino_Create_Bridge_cli
220+
run: mv -v ${{ matrix.executable-path }}arduino-create-agent_cli${{ matrix.extension }} ${{ matrix.executable-path }}Arduino_Create_Bridge_cli${{ matrix.extension }}
221+
if: matrix.operating-system == 'ubuntu-latest'
222+
223+
- name: Save InstallBuilder license to file
224+
run: echo "${{ secrets.INSTALLER_LICENSE }}" > /tmp/license.xml
225+
226+
- name: Save Win signing certificate to file
227+
run: echo "${{ secrets.INSTALLER_CERT_WINDOWS_PFX }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_PFX}}
228+
if: matrix.operating-system == 'windows-latest'
229+
230+
- name: Save macos signing certificate to file
231+
run: echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_P12 }}
232+
if: matrix.operating-system == 'macos-latest'
233+
234+
# win(edge),mac(safari) -> CERT_INSTALL and win,mac:(ff,chrome) -> CHOICE_CERT_INSTALL
235+
# installbuilder reads the env vars with certs paths and use it to sign the installer.
236+
- name: Launch Bitrock installbuilder-20 with CERT_INSTALL && CHOICE_CERT_INSTALL
237+
run: |
238+
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CERT_INSTALL }}
239+
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CI${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-${{matrix.browser}}${{matrix.installer-extension}}
240+
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CHOICE_CERT_INSTALL }}
241+
cp -vr ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-chrome${{matrix.installer-extension}}
242+
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-firefox${{matrix.installer-extension}}
243+
rm -r ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-C*
244+
if: matrix.operating-system == 'windows-latest' || matrix.operating-system == 'macos-latest'
245+
246+
# linux
247+
- name: Launch Bitrock installbuilder-20 with NO_CERT_INSTALL
248+
run: |
249+
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.NO_CERT_INSTALL }}
250+
cp -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CS.run ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-chrome.run
251+
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CS.run ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-firefox.run
252+
cp -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CS.tar.gz ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-chrome.tar.gz
253+
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CS.tar.gz ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-firefox.tar.gz
254+
if: matrix.operating-system == 'ubuntu-latest'
255+
256+
- name: Upload artifacts
257+
uses: actions/upload-artifact@v2
258+
with:
259+
name: ArduinoCreateAgent-${{ matrix.install-builder-name }}
260+
path: ArduinoCreateAgent*
261+
if-no-files-found: error
262+
263+
# This job will sign and notarize mac installers
264+
code-sign-mac-installers:
265+
needs: package
266+
runs-on: macos-latest
267+
268+
strategy:
269+
matrix:
270+
browser: [safari, firefox, chrome]
271+
272+
steps:
273+
274+
- name: Download artifact
275+
uses: actions/download-artifact@v2
276+
with:
277+
name: ArduinoCreateAgent-osx
278+
path: ArduinoCreateAgent-osx
279+
280+
# workaround to strip bugfix number from semver (only to make 1.1 release) I will change this in the future
281+
- name: Set version env vars
282+
# VERSION will be available only in the next step
283+
run: |
284+
echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
285+
286+
# zip artifacts do not mantain executable permission
287+
- name: Make executable
288+
run: chmod -v +x ArduinoCreateAgent-osx/ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.app/Contents/MacOS/*
289+
290+
- name: Import Code-Signing Certificates
291+
env:
292+
KEYCHAIN: "sign.keychain"
293+
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
294+
run: |
295+
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_PATH }}
296+
security create-keychain -p ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
297+
security default-keychain -s ${{ env.KEYCHAIN }}
298+
security unlock-keychain -p ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
299+
security import ${{ env.INSTALLER_CERT_MAC_PATH }} -k ${{ env.KEYCHAIN }} -f pkcs12 -A -T /usr/bin/codesign -P ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}
300+
security set-key-partition-list -S apple-tool:,apple: -s -k ${{ secrets.KEYCHAIN_PASSWORD }} ${{ env.KEYCHAIN }}
301+
302+
- name: Install gon for code signing and app notarization
303+
run: |
304+
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
305+
unzip gon_macos.zip -d /usr/local/bin
306+
307+
- name: Write gon config to file
308+
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
309+
run: |
310+
cat > gon.config_installer.hcl <<EOF
311+
source = ["ArduinoCreateAgent-osx/ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.app"]
312+
bundle_id = "cc.arduino.arduino-agent-installer"
313+
314+
sign {
315+
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
316+
}
317+
318+
dmg {
319+
output_path = "ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.dmg"
320+
volume_name = "ArduinoCreateAgent"
321+
}
322+
EOF
323+
324+
- name: Code sign and notarize app
325+
env:
326+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
327+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
328+
run: |
329+
echo "gon will notarize executable in ArduinoCreateAgent-osx/ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.app"
330+
gon -log-level=debug -log-json gon.config_installer.hcl
331+
timeout-minutes: 30
332+
333+
# tar dmg file to keep executable permission
334+
- name: Tar files to keep permissions
335+
run: tar -cvf ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.tar ArduinoCreateAgent-${VERSION%.*}-osx-installer-${{ matrix.browser }}.dmg
336+
337+
- name: Upload artifacts
338+
uses: actions/upload-artifact@v2
339+
with:
340+
name: ArduinoCreateAgent-osx
341+
path: ArduinoCreateAgent*.tar
342+
if-no-files-found: error
343+
344+
create-release:
345+
runs-on: ubuntu-latest
346+
needs: code-sign-mac-installers
347+
env:
348+
PLUGIN_TARGET: "/CreateBridgeStable/"
349+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
350+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
351+
352+
steps:
353+
354+
- name: Download artifact
355+
uses: actions/download-artifact@v2 # download all the artifacts
356+
357+
- name: Identify Prerelease
358+
# This is a workaround while waiting for create-release action to implement auto pre-release based on tag
359+
id: prerelease
360+
run: |
361+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.1.0.zip
362+
unzip -p /tmp/3.1.0.zip semver-tool-3.1.0/src/semver >/tmp/semver && chmod +x /tmp/semver
363+
if [[ $(/tmp/semver get prerel ${GITHUB_REF/refs\/tags\//}) ]]; then echo "::set-output name=IS_PRE::true"; fi
364+
365+
# mandatory step because upload-release-action does not support multiple folders
366+
- name: prepare artifacts for the release
367+
run: |
368+
mkdir release
369+
chmod -v +x ArduinoCreateAgent-linux-x64/*.run
370+
mv -v ArduinoCreateAgent-linux-x64/* release/
371+
cat ArduinoCreateAgent-osx/*.tar | tar -xvf - -i -C release/
372+
rm -v release/._ArduinoCreateAgent*.dmg
373+
mv -v ArduinoCreateAgent-windows/* release/
374+
375+
- name: Create Github Release
376+
uses: actions/create-release@v1
377+
env:
378+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
379+
with:
380+
tag_name: ${{ github.ref }}
381+
release_name: ${{ github.ref }}
382+
body: ""
383+
draft: false
384+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
385+
386+
- name: Upload release files on Github
387+
uses: svenstaro/upload-release-action@v2
388+
with:
389+
repo_token: ${{ secrets.GITHUB_TOKEN }}
390+
tag: ${{ github.ref }}
391+
file_glob: true # If set to true, the file argument can be a glob pattern
392+
file: release/*
393+
394+
- name: Upload release files on Arduino downloads servers
395+
run: aws s3 sync release/ s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.PLUGIN_TARGET }} --include "*"
396+
if: steps.prerelease.outputs.IS_PRE != 'true'

0 commit comments

Comments
 (0)