Skip to content

Commit 2d88f11

Browse files
authored
[skip changelog] Sync "Publish Nightly Build" CI workflow with template (#1394)
* [skip changelog] Remove obsolete link footnotes from readme These have been replaced by more maintainable direct links. * [skip changelog] Sync "Publish Nightly Build" CI workflow with template 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: - Improved failure reporting - Manual triggers to allow publishing on demand
1 parent 7989a4e commit 2d88f11

File tree

4 files changed

+160
-138
lines changed

4 files changed

+160
-138
lines changed

.github/workflows/nightly.yaml

-132
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-nightly-task.md
2+
name: Publish Nightly Build
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
12+
13+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
14+
on:
15+
schedule:
16+
# run every day at 1AM
17+
- cron: "0 1 * * *"
18+
workflow_dispatch:
19+
repository_dispatch:
20+
21+
jobs:
22+
create-nightly-artifacts:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Install Task
30+
uses: arduino/setup-task@v1
31+
with:
32+
repo-token: ${{ secrets.GITHUB_TOKEN }}
33+
version: 3.x
34+
35+
- name: Build
36+
env:
37+
NIGHTLY: true
38+
run: task dist:all
39+
40+
- name: Upload artifacts
41+
uses: actions/upload-artifact@v2
42+
with:
43+
if-no-files-found: error
44+
name: ${{ env.ARTIFACT_NAME }}
45+
path: ${{ env.DIST_DIR }}
46+
47+
notarize-macos:
48+
runs-on: macos-latest
49+
needs: create-nightly-artifacts
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v2
54+
55+
- name: Download artifacts
56+
uses: actions/download-artifact@v2
57+
with:
58+
name: ${{ env.ARTIFACT_NAME }}
59+
path: ${{ env.DIST_DIR }}
60+
61+
- name: Import Code-Signing Certificates
62+
env:
63+
KEYCHAIN: "sign.keychain"
64+
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
65+
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
66+
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 \
72+
"${{ env.INSTALLER_CERT_MAC_PATH }}" \
73+
-k "${{ env.KEYCHAIN }}" \
74+
-f pkcs12 \
75+
-A \
76+
-T /usr/bin/codesign \
77+
-P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
78+
security set-key-partition-list \
79+
-S apple-tool:,apple: \
80+
-s \
81+
-k "${{ env.KEYCHAIN_PASSWORD }}" \
82+
"${{ env.KEYCHAIN }}"
83+
84+
- name: Install gon for code signing and app notarization
85+
run: |
86+
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
87+
unzip gon_macos.zip -d /usr/local/bin
88+
89+
- name: Sign and notarize binary
90+
env:
91+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
92+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
93+
run: |
94+
gon gon.config.hcl
95+
96+
- name: Re-package binary and update checksum
97+
# This step performs the following:
98+
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
99+
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
100+
run: |
101+
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
102+
# so we need to add execution permission back until the action is made to do this.
103+
chmod +x "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}"
104+
PACKAGE_FILENAME="$(basename ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_nightly-*_macOS_64bit.tar.gz)"
105+
tar -czvf "${{ env.DIST_DIR }}/$PACKAGE_FILENAME" \
106+
-C "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/" "${{ env.PROJECT_NAME }}" \
107+
-C ../../ LICENSE.txt
108+
CHECKSUM="$(shasum -a 256 ${{ env.DIST_DIR }}/$PACKAGE_FILENAME | cut -d " " -f 1)"
109+
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
110+
111+
- name: Upload artifacts
112+
uses: actions/upload-artifact@v2
113+
with:
114+
if-no-files-found: error
115+
name: ${{ env.ARTIFACT_NAME }}
116+
path: ${{ env.DIST_DIR }}
117+
118+
publish-nightly:
119+
runs-on: ubuntu-latest
120+
needs: notarize-macos
121+
122+
steps:
123+
- name: Download artifact
124+
uses: actions/download-artifact@v2
125+
with:
126+
name: ${{ env.ARTIFACT_NAME }}
127+
path: ${{ env.DIST_DIR }}
128+
129+
- name: Upload release files on Arduino downloads servers
130+
uses: docker://plugins/s3
131+
env:
132+
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
133+
PLUGIN_TARGET: "${{ env.AWS_PLUGIN_TARGET }}nightly"
134+
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
135+
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
136+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
137+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
138+
139+
report:
140+
runs-on: ubuntu-latest
141+
needs: publish-nightly
142+
if: failure() # Run if publish-nightly or any of its job dependencies failed
143+
144+
steps:
145+
- name: Report failure
146+
uses: masci/datadog@v1
147+
with:
148+
api-key: ${{ secrets.DD_API_KEY }}
149+
events: |
150+
- title: "${{ env.PROJECT_NAME }} nightly build failed"
151+
text: "Nightly build workflow has failed"
152+
alert_type: "error"
153+
host: ${{ github.repository }}
154+
tags:
155+
- "project:${{ env.PROJECT_NAME }}"
156+
- "workflow:${{ github.workflow }}"

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and many other tools needed to use any Arduino compatible board and platform.
77

88
[![Test Go status](https://github.com/arduino/arduino-cli/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/test-go-task.yml)
99
[![Test Integration status](https://github.com/arduino/arduino-cli/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/test-go-integration-task.yml)
10-
[![nightly-badge]](https://github.com/Arduino/arduino-cli/actions?workflow=nightly)
10+
[![Publish Nightly Build status](https://github.com/arduino/arduino-cli/actions/workflows/publish-go-nightly-task.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/publish-go-nightly-task.yml)
1111
[![Deploy Website status](https://github.com/arduino/arduino-cli/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml)
1212
[![Codecov](https://codecov.io/gh/arduino/arduino-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-cli)
1313

@@ -45,10 +45,6 @@ policy] and report the bug to our Security Team 🛡️ Thank you!
4545

4646
e-mail contact: [email protected]
4747

48-
[tests-badge]: https://github.com/Arduino/arduino-cli/workflows/test/badge.svg
49-
[nightly-badge]: https://github.com/Arduino/arduino-cli/workflows/nightly/badge.svg
50-
[docs-badge]: https://github.com/Arduino/arduino-cli/workflows/publish-docs/badge.svg
51-
[codecov-badge]: https://codecov.io/gh/arduino/arduino-cli/branch/master/graph/badge.svg
5248
[install]: https://arduino.github.io/arduino-cli/latest/installation
5349
[user documentation]: https://arduino.github.io/arduino-cli/latest/
5450
[getting started]: https://arduino.github.io/arduino-cli/latest/getting-started/

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/arduino-cli_osx_darwin_amd64/arduino-cli"]
24
bundle_id = "cc.arduino.arduino-cli"
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-cli.zip"
13+
output_path = "unused.zip"
1214
}

0 commit comments

Comments
 (0)