BlueGit

ict rusty-teams

Files

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

build.yml

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