Repository navigation
341 lines (295 loc) · 12.5 KB
/
Copy pathrelease-cpp.yml
File metadata and controls
341 lines (295 loc) · 12.5 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: Release Cpp
# Builds the moq C++ package (cpp/moq) for every target and publishes one archive per
# target to a cpp-v<version> GitHub release. The vcpkg and Conan packages fetch these.
on:
push:
tags:
- "cpp-v*"
# Dry-run: build everything, publish nothing. Nightly calls every release
# workflow this way so a broken build surfaces before the tag is cut.
workflow_call:
inputs:
reuse-native:
description: "Use this run's native input after its installed-consumer gate succeeds"
type: boolean
default: false
workflow_dispatch:
inputs:
prebuilt-test:
description: "Validate the same-revision shared default-feature input on all four hosts"
type: boolean
default: false
permissions:
contents: read
jobs:
native:
if: github.event_name == 'workflow_dispatch' && inputs.prebuilt-test
uses: ./.github/workflows/release-ffi.yml
with:
language: default
bindings: false
targets: '["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-pc-windows-msvc"]'
build:
name: Build (${{ matrix.target }})
needs: [native]
if: ${{ always() && !cancelled() }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/just
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
# openh264 assembles its x86_64 kernels with NASM, or falls back to slower C.
- uses: ./.github/actions/nasm
if: runner.os == 'Windows'
- uses: ./.github/actions/uniffi-bindgen
with:
generator: cpp
# The package version lives in cpp/moq/VERSION; a tag that disagrees is a mistake.
- name: Check version
if: github.ref_type == 'tag'
shell: bash
env:
TAG: ${{ github.ref_name }}
run: |
version=$(tr -d '[:space:]' < cpp/moq/VERSION)
if [[ "$TAG" != "cpp-v$version" ]]; then
echo "::error::tag $TAG does not match cpp/moq/VERSION ($version)"
exit 1
fi
- name: Refuse same-run input for a release tag
if: inputs.reuse-native && github.ref_type == 'tag'
run: |
echo "::error::cpp-v releases must use their immutable FFI_VERSION pin"
exit 1
- name: Download validated same-run input
if: inputs.reuse-native
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: cpp-native-${{ matrix.target }}
path: native-archive
- name: Parse prebuilt FFI version
if: inputs.reuse-native || (github.event_name == 'workflow_dispatch' && inputs.prebuilt-test)
id: ffi-version
run: just gh release parse-version moq-ffi
- name: Download shared input for compatibility check
if: github.event_name == 'workflow_dispatch' && inputs.prebuilt-test
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: default-lib-${{ matrix.target }}
path: native-library
- name: Stage shared input
if: github.event_name == 'workflow_dispatch' && inputs.prebuilt-test
shell: bash
env:
TARGET: ${{ matrix.target }}
VERSION: ${{ needs.native.outputs.version }}
run: just cpp ffi stage --version "$VERSION" --target "$TARGET" --library native-library --output native-stage
- name: Check installed consumers with shared input
if: github.event_name == 'workflow_dispatch' && inputs.prebuilt-test
shell: bash
run: just cpp check --ffi-dir "$GITHUB_WORKSPACE/native-stage"
- name: Archive checked input
if: github.event_name == 'workflow_dispatch' && inputs.prebuilt-test
run: just cpp ffi archive --directory native-stage --output native-archive
- name: Verify and extract validated input
if: inputs.reuse-native || (github.event_name == 'workflow_dispatch' && inputs.prebuilt-test)
shell: bash
env:
TARGET: ${{ matrix.target }}
VERSION: ${{ steps.ffi-version.outputs.version }}
run: just cpp ffi extract --version "$VERSION" --target "$TARGET" --directory native-archive --output native-input
- name: Build and package
shell: bash
env:
TARGET: ${{ matrix.target }}
PREBUILT_INPUT: ${{ inputs.reuse-native || (github.event_name == 'workflow_dispatch' && inputs.prebuilt-test) }}
run: |
args=(--target "$TARGET" --output dist)
if [[ "$PREBUILT_INPUT" == true ]]; then
args+=(--ffi-dir "$GITHUB_WORKSPACE/native-input")
fi
just cpp package "${args[@]}"
- name: Check packaged archive
shell: bash
env:
TARGET: ${{ matrix.target }}
run: |
version=$(tr -d '[:space:]' < cpp/moq/VERSION)
extension=tar.gz
[[ "$TARGET" == *-windows-* ]] && extension=zip
just cpp check --archive "dist/moq-cpp-$version-$TARGET.$extension"
- name: Upload artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: moq-cpp-${{ matrix.target }}
path: dist/*
release:
name: Release
needs: build
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/just
- name: Parse version
id: parse
run: just gh release parse-version cpp
- name: Find previous tag
id: prev_tag
run: just gh release prev-tag cpp
- name: Download artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
path: artifacts
merge-multiple: true
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_TITLE: "moq C++ v${{ steps.parse.outputs.version }}"
RELEASE_PREV_TAG: ${{ steps.prev_tag.outputs.tag }}
run: just gh release create artifacts
# The OBS plugin (cpp/obs) statically links the C++ package, so it ships with
# every release: rebuild it against the release just published (no second
# cargo build, guaranteed-matching bindings) and cut a parallel
# obs-moq-v<version> release. The plugin's version is its own,
# cpp/obs/VERSION. Tags wait for `release` so downloads are live; dry runs
# consume this run's checked local archive without publishing anything.
obs-build:
name: OBS plugin (${{ matrix.target }})
needs: [build, release]
if: ${{ always() && !cancelled() && needs.build.result == 'success' && (github.ref_type != 'tag' || needs.release.result == 'success') }}
runs-on: ${{ matrix.os }}
# macOS + Windows only. These link the ffmpeg the obs-deps bundle ships
# (the same one OBS uses), so the binaries are portable. A Linux build
# would link nix/distro ffmpeg and not be portable, so Linux is
# build-from-source (see doc/bin/obs.md) and ships no prebuilt binary.
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
# The plugin preset uses the Visual Studio 17 2022 generator.
os: windows-2022
steps:
# Shallow: this job only compiles, it never reads git history or tags.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/just
# The build job already checked the tag against this file.
- name: Read C++ version
id: parse
shell: bash
run: echo "version=$(tr -d '[:space:]' < cpp/moq/VERSION)" >>"$GITHUB_OUTPUT"
- name: Download local C++ archive
if: github.ref_type != 'tag'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: moq-cpp-${{ matrix.target }}
path: cpp-archive
# Native Xcode / Visual Studio; libobs/Qt6/ffmpeg come from the obs-deps
# bundle and C++ comes from the checked local archive, or the published tag.
# build.sh versions the plugin from cpp/obs/VERSION.
- name: Build and package
shell: bash
env:
TARGET: ${{ matrix.target }}
MOQ_RELEASE: ${{ steps.parse.outputs.version }}
REF_TYPE: ${{ github.ref_type }}
run: |
args=(--moq-release "$MOQ_RELEASE")
if [[ "$REF_TYPE" != tag ]]; then
extension=tar.gz
[[ "$TARGET" == *-windows-* ]] && extension=zip
args=(--moq-archive "$GITHUB_WORKSPACE/cpp-archive/moq-cpp-$MOQ_RELEASE-$TARGET.$extension")
fi
just obs package --target "$TARGET" "${args[@]}" --output dist
- name: Upload artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: obs-moq-${{ matrix.target }}
path: dist/*
obs-release:
name: OBS plugin release
needs: obs-build
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/just
- name: Read plugin version
id: parse
run: echo "version=$(tr -d '[:space:]' < cpp/obs/VERSION)" >>"$GITHUB_OUTPUT"
# An obs-moq tag names one build. A later C++ release without a plugin
# version bump would overwrite that release's archives, so refuse it; a
# re-run of this same release finds its tag on this commit and carries on.
- name: Refuse a reused plugin version
env:
VERSION: ${{ steps.parse.outputs.version }}
run: |
tag="obs-moq-v${VERSION}"
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null &&
[ "$(git rev-parse "refs/tags/$tag^{commit}")" != "$(git rev-parse HEAD)" ]; then
echo "::error::$tag already names another commit; bump cpp/obs/VERSION"
exit 1
fi
# Only the obs-moq archives: the moq-cpp-* artifacts from the build job
# belong to the C++ release, not this one.
- name: Download artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
path: artifacts
pattern: obs-moq-*
merge-multiple: true
# `just gh release prev-tag` keys off the current tag, but the trigger here is a
# cpp-v* tag, so it can't find the previous obs-moq tag. Take the newest
# existing obs-moq tag (excluding this version, for safe re-runs) so the
# release notes span only since the last obs-moq release.
- name: Find previous obs-moq tag
id: prev_tag
env:
VERSION: ${{ steps.parse.outputs.version }}
run: |
cur="obs-moq-v${VERSION}"
# awk (not grep -vx | head) so an empty result is exit 0, not 1:
# under `set -eo pipefail` the inaugural release has no prior tag and
# grep's exit 1 would fail the step. Empty tag is fine downstream.
prev=$(git tag --list 'obs-moq-v*' --sort=-v:refname | awk -v cur="$cur" '$0 != cur { print; exit }')
echo "tag=${prev}" >>"$GITHUB_OUTPUT"
# Cut a parallel obs-moq-v<version> release at this commit (gh creates
# the tag).
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: "obs-moq-v${{ steps.parse.outputs.version }}"
RELEASE_TITLE: "obs-moq v${{ steps.parse.outputs.version }}"
RELEASE_PREV_TAG: ${{ steps.prev_tag.outputs.tag }}
run: just gh release create artifacts