BlueGit

ict rusty-teams

Files

rusty-teams / .github / workflows / build.yml

build.yml

7059d5ef History
build.yml 12.9 KiB Download Raw
1# Builds per README "Quick start": `cargo build -p app`, plus the universal macOS
2# binary from scripts/build-macos.sh and the Linux packages from
3# packaging/linux/package.sh. Tests live in test.yml; this file only packages the
4# artifacts.
5name: Build
6
7# Builds run for tags (the release assets); pushes are tested in test.yml.
8# A `v*` tag also publishes a GitHub release; a tag with `-` (v0.2.0-rc.1) is a pre-release.
9# nightly.yml starts it with workflow_dispatch on a nightly tag.
10on:
11 push:
12 tags: ['*']
13 workflow_dispatch:
14
15permissions:
16 contents: read
17
18concurrency:
19 group: ${{ github.workflow }}-${{ github.ref }}
20 cancel-in-progress: true
21
22env:
23 CARGO_TERM_COLOR: always
24
25jobs:
26 linux:
27 name: Linux
28 # The oldest supported Ubuntu LTS: the binary needs the glibc it was built
29 # against, so building here lets it, the AppImage and the deb/rpm run on
30 # glibc 2.35 and newer.
31 runs-on: ubuntu-22.04
32 timeout-minutes: 90
33 # webrtc-sys compiles its C++ against the hermetic libc++ inside the libwebrtc
34 # artifact, which needs a clang as new as that libc++ (clang 21 today, see
35 # check_clang_version in vendor/webrtc-sys/build.rs). The distro clang is older
36 # (18 on ubuntu-24.04), so setup-linux installs clang 21 and these point every
37 # compile and the final link at it.
38 env:
39 CC: clang-21
40 CXX: clang++-21
41 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: clang-21
42 steps:
43 - uses: actions/checkout@v6
44
45 - uses: ./.github/actions/setup-linux
46
47 - uses: dtolnay/rust-toolchain@stable
48
49 # Its own key: build scripts cached on a newer Ubuntu would need a newer glibc.
50 - uses: Swatinem/rust-cache@v2
51 with:
52 key: build-ubuntu-22.04
53
54 - name: Build
55 run: cargo build -p app --release
56
57 # Before packaging. A later Flatpak or package failure must not drop the binary.
58 - uses: actions/upload-artifact@v7
59 with:
60 name: teams-linux-amd64
61 path: target/release/teams
62 if-no-files-found: error
63
64 # nfpm builds the deb and rpm, zsync the AppImage's .zsync; desktop-file-utils
65 # and appstream validate the metadata. AppImage tooling is downloaded by
66 # package.sh at pinned digests.
67 - name: Install packaging tools
68 env:
69 NFPM_VERSION: 2.48.0
70 NFPM_SHA256: 787af76e172dd5fc7cedf4d7c5a090a2f62be9001557a4db1103e270f90ddefd
71 run: |
72 sudo apt-get install --no-install-recommends -y zsync desktop-file-utils appstream
73 curl -fsSL -o "$RUNNER_TEMP/nfpm.deb" \
74 "https://github.com/goreleaser/nfpm/releases/download/v$NFPM_VERSION/nfpm_${NFPM_VERSION}_amd64.deb"
75 echo "$NFPM_SHA256 $RUNNER_TEMP/nfpm.deb" | sha256sum -c -
76 sudo dpkg -i "$RUNNER_TEMP/nfpm.deb"
77
78 # A tag build carries the tag's version (v0.5.0-rc.1 -> 0.5.0~rc.1 in the deb).
79 - name: Package
80 env:
81 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
82 run: packaging/linux/package.sh --skip-build --formats "appimage deb rpm"
83
84 # deb, rpm, AppImage and its .zsync. Uploaded before Arch and Flatpak, so a
85 # later failure leaves these artifacts in the run.
86 - uses: actions/upload-artifact@v7
87 with:
88 name: teams-linux-packages
89 path: dist/release/*
90 if-no-files-found: error
91
92 # Arch is its own artifact. A failure here does not drop deb/rpm/AppImage,
93 # and Flatpak still runs. The job goes red at the end if either is missing.
94 - name: Arch
95 id: arch
96 continue-on-error: true
97 env:
98 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
99 run: packaging/linux/package.sh --skip-build --formats archlinux
100
101 - uses: actions/upload-artifact@v7
102 if: steps.arch.outcome == 'success'
103 with:
104 name: teams-linux-arch
105 path: dist/release/*.pkg.tar.zst
106 if-no-files-found: error
107
108 # The Flatpak repackages a tarball built only for it; the release keeps its own tarball.
109 - name: Flatpak
110 id: flatpak
111 continue-on-error: true
112 env:
113 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
114 run: |
115 # 22.04's flatpak-builder 1.2 still calls appstream-compose, which the 26.08 SDK dropped.
116 sudo add-apt-repository -y ppa:flatpak/stable
117 sudo apt-get install --no-install-recommends -y flatpak flatpak-builder
118 DIST="$RUNNER_TEMP/flatpak" packaging/linux/package.sh --skip-build --formats tar
119 packaging/linux/flatpak-bundle.sh --no-test "$RUNNER_TEMP"/flatpak/rusty-teams-*-linux-x86_64.tar.gz
120
121 - uses: actions/upload-artifact@v7
122 if: steps.flatpak.outcome == 'success'
123 with:
124 name: teams-linux-flatpak
125 path: dist/release/*.flatpak
126 if-no-files-found: error
127
128 - name: Require Arch and Flatpak
129 if: steps.arch.outcome != 'success' || steps.flatpak.outcome != 'success'
130 run: |
131 echo "arch=${{ steps.arch.outcome }} flatpak=${{ steps.flatpak.outcome }}"
132 exit 1
133
134 windows:
135 name: Windows
136 runs-on: windows-latest
137 timeout-minutes: 90
138 defaults:
139 run:
140 shell: bash
141 steps:
142 - uses: actions/checkout@v6
143
144 - uses: dtolnay/rust-toolchain@stable
145
146 - uses: Swatinem/rust-cache@v2
147 with:
148 key: build
149
150 # After the toolchain: staging runs `cargo metadata`.
151 - uses: ./.github/actions/setup-windows
152
153 # fxc.exe comes from the Windows SDK, gpui-pre-windows finds it through the registry.
154 - name: Build
155 run: cargo build -p app --release --config "patch.crates-io.gpui-pre-windows.path=\"$GPUI_PRE_WINDOWS_PATCHED\""
156
157 # The runner is x86_64; the artifact name carries the architecture.
158 - uses: actions/upload-artifact@v7
159 with:
160 name: teams-windows-amd64
161 path: target/release/teams.exe
162
163 windows-arm:
164 name: Windows ARM64
165 runs-on: windows-11-arm
166 timeout-minutes: 90
167 defaults:
168 run:
169 shell: bash
170 steps:
171 - uses: actions/checkout@v6
172
173 - uses: dtolnay/rust-toolchain@stable
174
175 - uses: Swatinem/rust-cache@v2
176 with:
177 key: build-windows-arm
178
179 # After the toolchain: staging runs `cargo metadata` for aarch64.
180 - uses: ./.github/actions/setup-windows
181
182 - name: Build
183 run: cargo build -p app --release --config "patch.crates-io.gpui-pre-windows.path=\"$GPUI_PRE_WINDOWS_PATCHED\""
184
185 - uses: actions/upload-artifact@v7
186 with:
187 name: teams-windows-arm64
188 path: target/release/teams.exe
189
190 macos:
191 name: macOS
192 runs-on: macos-latest
193 timeout-minutes: 90
194 steps:
195 - uses: actions/checkout@v6
196
197 - uses: dtolnay/rust-toolchain@stable
198
199 - uses: Swatinem/rust-cache@v2
200 with:
201 key: build
202
203 # scripts/build-macos.sh builds the arm64 and x86_64 slices, lipos them into
204 # one universal binary and wraps it in a .app with the icon (README "Quick
205 # start"); it installs the x86_64 rustup target itself and needs Xcode CLT only.
206 - name: Build
207 run: scripts/build-macos.sh crates/app teams
208
209 - uses: actions/upload-artifact@v7
210 with:
211 name: teams-macos
212 path: target/universal/release/teams-macos.zip
213
214 release:
215 name: Release
216 needs: [linux, windows, windows-arm, macos]
217 # A failed platform must not hide the artifacts the other jobs already uploaded.
218 # The job stays red afterwards when an expected asset is missing.
219 if: always() && !cancelled() && startsWith(github.ref, 'refs/tags/v')
220 runs-on: ubuntu-latest
221 permissions:
222 contents: write
223 steps:
224 # Full history and tags for the release notes.
225 - uses: actions/checkout@v6
226 with:
227 fetch-depth: 0
228
229 - uses: actions/download-artifact@v8
230 with:
231 path: dist
232
233 # Highlights from the body of the chore(release) commit, then git-cliff's list
234 # of every feat and fix since the previous release (cliff.toml).
235 - name: Release notes
236 env:
237 TAG: ${{ github.ref_name }}
238 GITHUB_TOKEN: ${{ github.token }}
239 GIT_CLIFF_VERSION: 2.14.2
240 GIT_CLIFF_SHA256: 24f397c733add5390fdceee3a2088588ab0d5f944ce00d34cb7029b888cf2db4
241 run: |
242 set -euo pipefail
243 archive="git-cliff-$GIT_CLIFF_VERSION-x86_64-unknown-linux-gnu.tar.gz"
244 curl -fsSL -o "$RUNNER_TEMP/$archive" \
245 "https://github.com/orhun/git-cliff/releases/download/v$GIT_CLIFF_VERSION/$archive" &&
246 echo "$GIT_CLIFF_SHA256 $RUNNER_TEMP/$archive" | sha256sum -c - &&
247 tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" || true
248 cliff="$RUNNER_TEMP/git-cliff-$GIT_CLIFF_VERSION/git-cliff"
249 highlights="$(git log -1 --format=%b "$TAG" | grep -v -e '^Co-Authored-By:' -e 'Workspace version' | sed '/./,$!d' || true)"
250 # Notes must never block publishing the assets.
251 if ! {
252 # cliff.toml's tag_pattern skips nightly tags: a nightly lists everything since the last release.
253 if [[ "$TAG" == *-nightly.* ]]; then
254 printf 'Nightly build of main at %s. Not a release.\n\n' "$(git rev-parse --short "$TAG")"
255 "$cliff" --config cliff.toml --unreleased --strip all
256 elif [[ -n "${highlights//[[:space:]]/}" ]]; then
257 printf '## Highlights\n\n%s\n\n<details>\n<summary>All changes</summary>\n\n' "$highlights"
258 "$cliff" --config cliff.toml --current --strip all
259 printf '\n</details>\n'
260 else
261 "$cliff" --config cliff.toml --current --strip all
262 fi
263 } > "$RUNNER_TEMP/notes.md"; then
264 echo "Release notes could not be generated, see the commits since the previous tag." > "$RUNNER_TEMP/notes.md"
265 fi
266 cat "$RUNNER_TEMP/notes.md"
267
268 # Artifacts drop the executable bit, the tarball restores it.
269 # Asset names use the version without the leading v (rusty-teams-0.5.0-…).
270 - name: Package
271 id: package
272 env:
273 TAG: ${{ github.ref_name }}
274 run: |
275 set -euo pipefail
276 ver="${TAG#v}"
277 mkdir release
278 missing=()
279 take() {
280 local src="$1" dest="$2" label="$3"
281 if [[ -f "$src" ]]; then
282 cp "$src" "$dest"
283 else
284 echo "missing $label" >&2
285 missing+=("$label")
286 fi
287 }
288 if [[ -f dist/teams-linux-amd64/teams ]]; then
289 chmod +x dist/teams-linux-amd64/teams
290 tar -czf "release/rusty-teams-$ver-linux-amd64.tar.gz" -C dist/teams-linux-amd64 teams
291 # The bare binary is what the Linux self-update downloads (release_feed.rs).
292 cp dist/teams-linux-amd64/teams "release/rusty-teams-$ver-linux-amd64"
293 else
294 missing+=("linux-amd64")
295 fi
296 take dist/teams-windows-amd64/teams.exe "release/rusty-teams-$ver-windows-amd64.exe" "windows-amd64"
297 take dist/teams-windows-arm64/teams.exe "release/rusty-teams-$ver-windows-arm64.exe" "windows-arm64"
298 take dist/teams-macos/teams-macos.zip "release/rusty-teams-$ver-macos-universal.zip" "macos"
299 shopt -s nullglob
300 packages=(dist/teams-linux-packages/*)
301 if (( ${#packages[@]} )); then
302 # deb, rpm, AppImage and its .zsync. The AppImage update information looks for that .zsync name.
303 cp "${packages[@]}" release/
304 else
305 missing+=("linux-packages")
306 fi
307 flatpaks=(dist/teams-linux-flatpak/*.flatpak)
308 if (( ${#flatpaks[@]} )); then
309 cp "${flatpaks[@]}" release/
310 else
311 missing+=("flatpak")
312 fi
313 archpkgs=(dist/teams-linux-arch/*.pkg.tar.zst)
314 if (( ${#archpkgs[@]} )); then
315 cp "${archpkgs[@]}" release/
316 else
317 missing+=("arch")
318 fi
319 assets=(release/*)
320 if (( ${#assets[@]} )); then
321 echo "publish=true" >> "$GITHUB_OUTPUT"
322 else
323 echo "publish=false" >> "$GITHUB_OUTPUT"
324 fi
325 if (( ${#missing[@]} )); then
326 echo "complete=false" >> "$GITHUB_OUTPUT"
327 echo "missing=${missing[*]}" >> "$GITHUB_OUTPUT"
328 else
329 echo "complete=true" >> "$GITHUB_OUTPUT"
330 echo "missing=" >> "$GITHUB_OUTPUT"
331 fi
332
333 - uses: softprops/action-gh-release@v3
334 if: steps.package.outputs.publish == 'true'
335 with:
336 files: release/*
337 body_path: ${{ runner.temp }}/notes.md
338 prerelease: ${{ contains(github.ref_name, '-') }}
339
340 - name: Fail when an asset is missing
341 if: always() && !cancelled() && steps.package.outputs.complete != 'true'
342 run: |
343 echo "Published the assets that were built. Still missing: ${{ steps.package.outputs.missing }}"
344 exit 1