Skip to content

Commit b4df117

Browse files
authored
Merge pull request #19 from arduino/go-cross
Add CI workflow to publish releases
2 parents 1e7da91 + 0227b7e commit b4df117

File tree

7 files changed

+525
-26
lines changed

7 files changed

+525
-26
lines changed

.github/workflows/release-go-task.yml

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
compile.sh
2+
libusb-*
23
dfu-util-*/*
34
dfu-discovery
45
*.o
56
dfu-util_*.c
7+
dist/

0 commit comments

Comments
 (0)