Repository navigation
262 lines (243 loc) · 10.8 KB
/
Copy path_build.yml
File metadata and controls
262 lines (243 loc) · 10.8 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Build
on:
workflow_call:
inputs:
source-sha:
required: false
type: string
default: ""
runs-on:
required: true
type: string
rust-target:
required: false
type: string
default: ""
wheel-smoke:
required: false
type: boolean
default: false
sign-windows:
description: >-
Authenticode-sign fastled.exe via Azure Artifact Signing before it is
bundled or uploaded (auto-release.yml only; the caller must grant
id-token: write and pass the AZURE_* secrets).
required: false
type: boolean
default: false
secrets:
AZURE_CLIENT_ID:
required: false
AZURE_TENANT_ID:
required: false
AZURE_SIGNING_ENDPOINT:
required: false
AZURE_SIGNING_ACCOUNT:
required: false
AZURE_SIGNING_PROFILE:
required: false
AZURE_SIGN_PUBLISHER:
required: false
jobs:
build:
runs-on: ${{ inputs.runs-on }}
timeout-minutes: 30
# Release dispatches come from a candidate branch, not main, so the OIDC
# subject must be environment-form for Azure to trust it. Unsigned builds
# declare no environment.
environment: ${{ inputs.sign-windows && 'release' || '' }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.source-sha || github.sha }}
- name: Verify checkout SHA
env:
EXPECTED_SHA: ${{ inputs.source-sha || github.sha }}
run: |
[[ "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]]
if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then
test "$EXPECTED_SHA" = "$GITHUB_SHA"
fi
test "$(git rev-parse HEAD)" = "$EXPECTED_SHA"
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: "3.11.9"
- name: Install Python
run: uv python install "$UV_PYTHON"
- name: Configure Rust target
run: |
cp rust-toolchain.toml rust-toolchain.ci.toml
if [ -n "${{ inputs.rust-target }}" ]; then
printf '\ntargets = ["%s"]\n' "${{ inputs.rust-target }}" >> rust-toolchain.ci.toml
fi
cat rust-toolchain.ci.toml
# Must run before setup-soldr: its soldr-cook step builds glib-sys /
# gobject-sys, which resolve GTK/WebKit through pkg-config. Cooking first
# fails with exit 101 and every run then compiles those deps cold (#262).
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- uses: zackees/setup-soldr@v0 # v0.9.82 or later (floating major)
env:
GITHUB_TOKEN: ${{ github.token }}
with:
# No soldr version pin: v0.7.53 (zccache v1.11.20) breaks the
# aarch64-pc-windows-msvc cross-compile with silent rustc failures
# (see #158); the action default v0.7.51 is green here.
# cache-preset: foundation expands to build-cache: true +
# target-cache: false + cargo-registry-cache: false +
# prebuild-deps: soldr-cook (setup-soldr v0.9.17+, #251).
cache-preset: foundation
# Include the rust target: the same runner label hosts multiple
# cross-compile targets (e.g. windows-2025 builds both x86_64 and
# aarch64-pc-windows-msvc), which would otherwise thrash one key.
# "-native" lines up with the lint/test workflows' suffix so jobs
# on the same platform share one cache namespace.
cache-key-suffix: ${{ inputs.runs-on }}-${{ inputs.rust-target || 'native' }}
linker: platform-default
toolchain-file: rust-toolchain.ci.toml
# x86_64-unknown-linux-gnu is the runner's own triple, so it builds
# natively, without `--target`. Naming it makes soldr switch to its
# glibc-2.17 catalogue sysroot and point PKG_CONFIG_LIBDIR there, which
# hides Ubuntu's GTK/WebKit from pkg-config, so glib-sys fails (#285).
# The artifact names and wheel plat tag still use inputs.rust-target.
- name: Build fastled CLI binary (for wheel bundling)
env:
CARGO_TARGET_TRIPLE: ${{ inputs.rust-target != 'x86_64-unknown-linux-gnu' && inputs.rust-target || '' }}
run: |
if [ -n "$CARGO_TARGET_TRIPLE" ]; then
soldr cargo build --release --bin fastled --target "$CARGO_TARGET_TRIPLE"
case "$CARGO_TARGET_TRIPLE" in
*windows*) EXE_NAME="fastled.exe" ;;
*) EXE_NAME="fastled" ;;
esac
BIN_SRC="target/$CARGO_TARGET_TRIPLE/release/${EXE_NAME}"
else
soldr cargo build --release --bin fastled
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*) EXE_NAME="fastled.exe" ;;
*) EXE_NAME="fastled" ;;
esac
if [ -n "${CARGO_BUILD_TARGET:-}" ] || [ "$EXE_NAME" = "fastled.exe" ]; then
ARCH="$(uname -m)"
if [ "$ARCH" = "x86_64" ]; then TRIPLE="x86_64-pc-windows-msvc"; else TRIPLE="aarch64-pc-windows-msvc"; fi
if [ -f "target/${TRIPLE}/release/${EXE_NAME}" ]; then
BIN_SRC="target/${TRIPLE}/release/${EXE_NAME}"
else
BIN_SRC="target/release/${EXE_NAME}"
fi
else
BIN_SRC="target/release/${EXE_NAME}"
fi
fi
mkdir -p src/fastled/bin
cp -f "$BIN_SRC" "src/fastled/bin/${EXE_NAME}"
ls -lh src/fastled/bin/
# Azure Artifact Signing (Authenticode), OIDC only. Signs the cargo
# output in place (setup.py re-copies it into the wheel) and the bundled
# copy, before the wheel is built or anything is uploaded, so the
# release zip, the PyPI wheel and the binary artifact carry signed bytes.
- name: Azure login for Authenticode signing
if: inputs.sign-windows && github.event_name != 'pull_request'
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Authenticode-sign fastled.exe
if: inputs.sign-windows && github.event_name != 'pull_request'
env:
AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
AZURE_SIGNING_PROFILE: ${{ secrets.AZURE_SIGNING_PROFILE }}
AZURE_SIGN_PUBLISHER: ${{ secrets.AZURE_SIGN_PUBLISHER }}
RUST_TARGET: ${{ inputs.rust-target }}
run: |
case "$RUST_TARGET" in
*-pc-windows-msvc) ;;
*) echo "::error::sign-windows requires a Windows rust-target, got '$RUST_TARGET'" >&2; exit 1 ;;
esac
python ci/sign_windows_release.py sign \
--file "target/$RUST_TARGET/release/fastled.exe" \
--file src/fastled/bin/fastled.exe
- name: Build wheel
env:
# setup.py rebuilds the bundled binary; keep that rebuild on the
# requested target, especially Windows ARM on an x64 runner.
# Native for x86_64 Linux, for the same reason as the build step.
FASTLED_RUST_TARGET: ${{ inputs.rust-target != 'x86_64-unknown-linux-gnu' && inputs.rust-target || '' }}
run: |
PLAT_NAME=""
case "${{ inputs.rust-target }}" in
aarch64-pc-windows-msvc) PLAT_NAME="win_arm64" ;;
x86_64-pc-windows-msvc) PLAT_NAME="win_amd64" ;;
aarch64-apple-darwin) PLAT_NAME="macosx_11_0_arm64" ;;
x86_64-apple-darwin) PLAT_NAME="macosx_10_12_x86_64" ;;
aarch64-unknown-linux-gnu) PLAT_NAME="manylinux_2_28_aarch64" ;;
x86_64-unknown-linux-gnu) PLAT_NAME="manylinux_2_28_x86_64" ;;
esac
if [ -n "$PLAT_NAME" ]; then
uv run --with "setuptools>=69" --with "wheel>=0.43" python setup.py bdist_wheel --plat-name "$PLAT_NAME"
else
uv run --with "setuptools>=69" --with "wheel>=0.43" python setup.py bdist_wheel
fi
# Fail closed: the bytes that ship (wheel member and binary artifact)
# must carry the signature, and Windows must report it Valid.
- name: Verify shipped Windows binaries are signed
if: inputs.sign-windows && github.event_name != 'pull_request'
env:
AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
AZURE_SIGNING_PROFILE: ${{ secrets.AZURE_SIGNING_PROFILE }}
AZURE_SIGN_PUBLISHER: ${{ secrets.AZURE_SIGN_PUBLISHER }}
run: |
shopt -s nullglob
wheels=(dist/*.whl)
test "${#wheels[@]}" -eq 1
python ci/sign_windows_release.py verify \
--file src/fastled/bin/fastled.exe --wheel "${wheels[0]}"
python ci/sign_windows_release.py smoke --file src/fastled/bin/fastled.exe
# Installs the wheel into a fresh venv and runs the packaged console
# script outside this checkout, in the shipped viewer.
- name: Smoke test installed wheel in shipped viewer
if: inputs.wheel-smoke
run: bash ci/smoke_installed_wheel.sh
- name: Upload installed wheel viewer screenshot
if: always() && inputs.wheel-smoke
uses: actions/upload-artifact@v4
with:
name: smoke-wheel-screenshot-${{ inputs.runs-on }}-${{ inputs.rust-target || 'native' }}
path: ${{ runner.temp }}/fastled-wheel-smoke/artifacts/*.png
if-no-files-found: error
- name: Upload installed wheel viewer log
if: always() && inputs.wheel-smoke
uses: actions/upload-artifact@v4
with:
name: smoke-wheel-log-${{ inputs.runs-on }}-${{ inputs.rust-target || 'native' }}
path: ${{ runner.temp }}/fastled-wheel-smoke/artifacts/*.log
if-no-files-found: warn
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ inputs.runs-on }}-${{ inputs.rust-target || 'native' }}
path: dist/*.whl
if-no-files-found: error
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-${{ inputs.runs-on }}-${{ inputs.rust-target || 'native' }}
path: src/fastled/bin/fastled*
if-no-files-found: error
- name: Upload failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: failure-logs-build-${{ inputs.runs-on }}
path: logs/*
if-no-files-found: warn