-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (145 loc) · 6.22 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (145 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
# Cross-builds the Rust m32_flash binary for all four Arduino-supported hosts,
# packages the platform + tool tarballs, creates a GitHub Release for the
# pushed tag, uploads the tarballs as Release assets, and commits the rendered
# package_m32_index.json back to `main` (so the Boards Manager URL is stable).
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version (e.g. 0.0.1-alpha). Ignored for tag-triggered runs.'
required: false
default: '0.0.0-devbuild'
permissions:
contents: write
jobs:
build-rust:
name: Build Rust ${{ matrix.arduino_host }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-14
arduino_host: arm64-apple-darwin
ext: ''
# x86_64 macOS is cross-compiled from the macos-14 (Apple Silicon)
# runner because macos-13 (Intel) is being retired in 2026 and queue
# times are unreliable. Xcode CLT on macos-14 ship both SDKs, so
# `cargo build --target x86_64-apple-darwin` from arm64 works.
- target: x86_64-apple-darwin
runner: macos-14
arduino_host: x86_64-apple-darwin
ext: ''
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
arduino_host: x86_64-pc-linux-gnu
ext: ''
- target: x86_64-pc-windows-msvc
runner: windows-latest
arduino_host: x86_64-mingw32
ext: '.exe'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
tools/m32_flasher/target
key: cargo-${{ matrix.target }}-${{ hashFiles('tools/m32_flasher/Cargo.lock', 'tools/m32_flasher/Cargo.toml') }}
- name: Build release binary
working-directory: tools/m32_flasher
run: cargo build --release --target ${{ matrix.target }}
- name: Upload binary artefact
uses: actions/upload-artifact@v4
with:
name: m32_flash-${{ matrix.arduino_host }}
path: tools/m32_flasher/target/${{ matrix.target }}/release/m32_flash${{ matrix.ext }}
if-no-files-found: error
package:
name: Package + Release
needs: build-rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Resolve VERSION
id: ver
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
VER="${GITHUB_REF_NAME#v}"
else
VER="${{ github.event.inputs.version }}"
fi
echo "VERSION=$VER" >> "$GITHUB_OUTPUT"
echo "Resolved VERSION: $VER"
- name: Install system deps
run: sudo apt-get update && sudo apt-get install -y curl tar bzip2 python3
- name: Download Rust binaries
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Lay out RUST_BUILDS_DIR
id: rust_builds
run: |
mkdir -p rust_builds/{arm64-apple-darwin,x86_64-apple-darwin,x86_64-pc-linux-gnu,x86_64-mingw32}
mv artifacts/m32_flash-arm64-apple-darwin/m32_flash rust_builds/arm64-apple-darwin/
mv artifacts/m32_flash-x86_64-apple-darwin/m32_flash rust_builds/x86_64-apple-darwin/
mv artifacts/m32_flash-x86_64-pc-linux-gnu/m32_flash rust_builds/x86_64-pc-linux-gnu/
mv artifacts/m32_flash-x86_64-mingw32/m32_flash.exe rust_builds/x86_64-mingw32/
chmod +x rust_builds/*/m32_flash 2>/dev/null || true
echo "RUST_BUILDS_DIR=$GITHUB_WORKSPACE/rust_builds" >> "$GITHUB_OUTPUT"
ls -la rust_builds/*
- name: Build release artefacts
env:
RUST_BUILDS_DIR: ${{ steps.rust_builds.outputs.RUST_BUILDS_DIR }}
run: |
chmod +x scripts/m32_dev.py
./scripts/m32_dev.py package \
--version "${{ steps.ver.outputs.VERSION }}" \
--asset-url-prefix "https://github.com/${{ github.repository }}/releases/download/v${{ steps.ver.outputs.VERSION }}/"
- name: Upload release artefacts (workflow_dispatch only)
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: m32duino-${{ steps.ver.outputs.VERSION }}
path: release/
- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.ver.outputs.VERSION }}
name: v${{ steps.ver.outputs.VERSION }}
body: |
Boards-Manager package for the NI Komplete Kontrol M32.
**To install in Arduino IDE:**
1. Preferences → Additional Boards Manager URLs, add:
```
https://raw.githubusercontent.com/${{ github.repository }}/main/package_m32_index.json
```
2. Tools → Board → Boards Manager → search "M32" → install.
3. Select board *NI Komplete Kontrol M32*, flash your sketch.
files: |
release/m32-stm32-${{ steps.ver.outputs.VERSION }}.tar.bz2
release/m32-dfu-${{ steps.ver.outputs.VERSION }}-x86_64-apple-darwin.tar.bz2
release/m32-dfu-${{ steps.ver.outputs.VERSION }}-arm64-apple-darwin.tar.bz2
release/m32-dfu-${{ steps.ver.outputs.VERSION }}-x86_64-pc-linux-gnu.tar.bz2
release/m32-dfu-${{ steps.ver.outputs.VERSION }}-x86_64-mingw32.tar.bz2
- name: Commit updated package_m32_index.json to main
if: github.event_name == 'push'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout main || git checkout -b main
cp release/package_m32_index.json package_m32_index.json
git add package_m32_index.json
git commit -m "Release v${{ steps.ver.outputs.VERSION }}: update package_m32_index.json" || echo "no changes"
git push origin main