Skip to content

Commit 101fcd3

Browse files
Add CI workflow to publish releases
On every push of a tag named with a version format: - Build the project for all supported platforms. - Sign and notarize the macOS builds. - Create a GitHub release. - Builds and checksums are attached as release assets - A changelog generated from the commit history is added to the release description - If the tag has a pre-release version suffix, the GitHub release will be marked as a pre-release. - Upload the builds to Arduino's downloads server.
1 parent fa827ec commit 101fcd3

File tree

4 files changed

+308
-0
lines changed

4 files changed

+308
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-crosscompile-task.md
2+
name: Release
3+
4+
env:
5+
# As defined by the Taskfile's PROJECT_NAME variable
6+
PROJECT_NAME: arduino101load
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: /arduino101load/
11+
ARTIFACT_NAME: dist
12+
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
13+
GO_VERSION: "1.17"
14+
15+
on:
16+
push:
17+
tags:
18+
- "[0-9]+.[0-9]+.[0-9]+*"
19+
20+
jobs:
21+
create-release-artifacts:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
matrix:
26+
os:
27+
- Windows_32bit
28+
- Windows_64bit
29+
- Linux_32bit
30+
- Linux_64bit
31+
- Linux_ARMv6
32+
- Linux_ARMv7
33+
- Linux_ARM64
34+
- macOS_64bit
35+
- macOS_ARM64
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v3
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Create changelog
44+
# Avoid creating the same changelog for each os
45+
if: matrix.os == 'Windows_32bit'
46+
uses: arduino/create-changelog@v1
47+
with:
48+
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
49+
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
50+
case-insensitive-regex: true
51+
changelog-file-path: "${{ env.DIST_DIR }}/CHANGELOG.md"
52+
53+
- name: Install Go
54+
uses: actions/setup-go@v3
55+
with:
56+
go-version: ${{ env.GO_VERSION }}
57+
58+
- name: Install Task
59+
uses: arduino/setup-task@v1
60+
with:
61+
repo-token: ${{ secrets.GITHUB_TOKEN }}
62+
version: 3.x
63+
64+
- name: Build
65+
run: task dist:${{ matrix.os }}
66+
67+
- name: Upload artifacts
68+
uses: actions/upload-artifact@v3
69+
with:
70+
if-no-files-found: error
71+
name: ${{ env.ARTIFACT_NAME }}
72+
path: ${{ env.DIST_DIR }}
73+
74+
create-release:
75+
runs-on: ubuntu-latest
76+
needs: create-release-artifacts
77+
78+
steps:
79+
- name: Download artifact
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: ${{ env.ARTIFACT_NAME }}
83+
path: ${{ env.DIST_DIR }}
84+
85+
- name: Create checksum file
86+
working-directory: ${{ env.DIST_DIR}}
87+
run: |
88+
TAG="${GITHUB_REF/refs\/tags\//}"
89+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
90+
91+
- name: Identify Prerelease
92+
# This is a workaround while waiting for create-release action
93+
# to implement auto pre-release based on tag
94+
id: prerelease
95+
run: |
96+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
97+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
98+
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "IS_PRE=true" >> $GITHUB_OUTPUT; fi
99+
100+
- name: Create Github Release and upload artifacts
101+
uses: ncipollo/release-action@v1
102+
with:
103+
token: ${{ secrets.GITHUB_TOKEN }}
104+
bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
105+
draft: false
106+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
107+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
108+
# (all the files we need are in the DIST_DIR root)
109+
artifacts: ${{ env.DIST_DIR }}/*
110+
111+
- name: Upload release files on Arduino downloads servers
112+
uses: docker://plugins/s3
113+
env:
114+
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
115+
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
116+
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
117+
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
118+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
119+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

DistTasks.yml

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-crosscompile-task/DistTasks.yml
2+
version: "3"
3+
4+
# This taskfile is ideally meant to be project agnostic and could be dropped in
5+
# on other Go projects with minimal or no changes.
6+
#
7+
# To use it simply add the following lines to your main taskfile:
8+
# includes:
9+
# dist: ./DistTasks.yml
10+
#
11+
# The following variables must be declared in the including taskfile for the
12+
# build process to work correctly:
13+
# * DIST_DIR: the folder that will contain the final binaries and packages
14+
# * PROJECT_NAME: the name of the project, used in package name
15+
# * VERSION: the version of the project, used in package name and checksum file
16+
# * LD_FLAGS: flags used at build time
17+
#
18+
# The project MUST contain a LICENSE.txt file in the root folder or packaging will fail.
19+
20+
tasks:
21+
Windows_32bit:
22+
desc: Builds Windows 32 bit binaries
23+
env:
24+
GOOS: "windows"
25+
GOARCH: "386"
26+
GO386: "softfloat"
27+
cmds:
28+
- |
29+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}}.exe {{.LDFLAGS}}
30+
cd {{.DIST_DIR}}
31+
cp -R ../firmwares bin/
32+
zip {{.PACKAGE_NAME}} bin/{{.PROJECT_NAME}}.exe bin/firmwares
33+
vars:
34+
PACKAGE_PLATFORM: "Windows_32bit"
35+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.zip"
36+
37+
Windows_64bit:
38+
desc: Builds Windows 64 bit binaries
39+
env:
40+
GOOS: "windows"
41+
GOARCH: "amd64"
42+
cmds:
43+
- |
44+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}}.exe {{.LDFLAGS}}
45+
cd {{.DIST_DIR}}
46+
cp -R ../firmwares bin/
47+
zip {{.PACKAGE_NAME}} bin/{{.PROJECT_NAME}}.exe bin/firmwares
48+
vars:
49+
PACKAGE_PLATFORM: "Windows_64bit"
50+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.zip"
51+
52+
Linux_32bit:
53+
desc: Builds Linux 32 bit binaries
54+
env:
55+
GOOS: "linux"
56+
GOARCH: "386"
57+
GO386: "softfloat"
58+
cmds:
59+
- |
60+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
61+
cd {{.DIST_DIR}}
62+
cp -R ../firmwares bin/
63+
tar cz bin/ -f {{.PACKAGE_NAME}}
64+
vars:
65+
PACKAGE_PLATFORM: "Linux_32bit"
66+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
67+
68+
Linux_64bit:
69+
desc: Builds Linux 64 bit binaries
70+
env:
71+
GOOS: "linux"
72+
GOARCH: "amd64"
73+
cmds:
74+
- |
75+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
76+
cd {{.DIST_DIR}}
77+
cp -R ../firmwares bin/
78+
tar cz bin/ -f {{.PACKAGE_NAME}}
79+
vars:
80+
PACKAGE_PLATFORM: "Linux_64bit"
81+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
82+
83+
Linux_ARMv7:
84+
desc: Builds Linux ARMv7 binaries
85+
env:
86+
GOOS: "linux"
87+
GOARCH: "arm"
88+
GOARM: 7
89+
cmds:
90+
- |
91+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
92+
cd {{.DIST_DIR}}
93+
cp -R ../firmwares bin/
94+
tar cz bin/ -f {{.PACKAGE_NAME}}
95+
vars:
96+
PACKAGE_PLATFORM: "Linux_ARMv7"
97+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
98+
99+
Linux_ARMv6:
100+
desc: Builds Linux ARMv6 binaries
101+
env:
102+
GOOS: "linux"
103+
GOARCH: "arm"
104+
GOARM: 6
105+
cmds:
106+
- |
107+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
108+
cd {{.DIST_DIR}}
109+
cp -R ../firmwares bin/
110+
tar cz bin/ -f {{.PACKAGE_NAME}}
111+
vars:
112+
PACKAGE_PLATFORM: "Linux_ARMv6"
113+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
114+
115+
Linux_ARM64:
116+
desc: Builds Linux ARM64 binaries
117+
env:
118+
GOOS: "linux"
119+
GOARCH: "arm64"
120+
cmds:
121+
- |
122+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
123+
cd {{.DIST_DIR}}
124+
cp -R ../firmwares bin/
125+
tar cz bin/ -f {{.PACKAGE_NAME}}
126+
vars:
127+
PACKAGE_PLATFORM: "Linux_ARM64"
128+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
129+
130+
macOS_64bit:
131+
desc: Builds Mac OS X 64 bit binaries
132+
env:
133+
GOOS: "darwin"
134+
GOARCH: "amd64"
135+
cmds:
136+
- |
137+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
138+
cd {{.DIST_DIR}}
139+
cp -R ../firmwares bin/
140+
tar cz bin/ -f {{.PACKAGE_NAME}}
141+
vars:
142+
PACKAGE_PLATFORM: "macOS_64bit"
143+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
144+
145+
macOS_ARM64:
146+
desc: Builds Mac OS X ARM64 binaries
147+
env:
148+
GOOS: "darwin"
149+
GOARCH: "arm64"
150+
cmds:
151+
- |
152+
go build -o {{.DIST_DIR}}/bin/{{.PROJECT_NAME}} {{.LDFLAGS}}
153+
cd {{.DIST_DIR}}
154+
cp -R ../firmwares bin/
155+
tar cz bin/ -f {{.PACKAGE_NAME}}
156+
vars:
157+
PACKAGE_PLATFORM: "macOS_ARM64"
158+
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# arduino101load
2+
[![Release status](https://github.com/arduino/arduino101load/actions/workflows/release-go-crosscompile-task.yml/badge.svg)](https://github.com/arduino/arduino101load/actions/workflows/release-go-crosscompile-task.yml)
23
multiplatform launcher for Arduino101 dfu-util flashing utility
34

45
## Compiling

Taskfile.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
4+
includes:
5+
dist: ./DistTasks.yml
6+
7+
vars:
8+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
9+
PROJECT_NAME: arduino101load
10+
DIST_DIR: "dist"
11+
# build vars
12+
COMMIT:
13+
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
14+
TIMESTAMP:
15+
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
16+
TIMESTAMP_SHORT:
17+
sh: echo "{{now | date "20060102"}}"
18+
TAG:
19+
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
20+
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
21+
CONFIGURATION_PACKAGE: "github.com/arduino/arduino101load/version"
22+
LDFLAGS: >-
23+
-ldflags
24+
'
25+
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}}
26+
-X {{.CONFIGURATION_PACKAGE}}.commit={{.COMMIT}}
27+
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
28+
'
29+
30+
tasks: {}

0 commit comments

Comments
 (0)