-
Notifications
You must be signed in to change notification settings - Fork 0
338 lines (298 loc) · 9.68 KB
/
release.yml
File metadata and controls
338 lines (298 loc) · 9.68 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
name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Read Cargo version and validate tag
id: version
shell: bash
run: |
set -euo pipefail
version="$(grep -m 1 '^version = "' src-tauri/Cargo.toml | cut -d '"' -f 2)"
if [[ -z "${version}" ]]; then
echo "Could not read version from src-tauri/Cargo.toml" >&2
exit 1
fi
expected_tag="v${version}"
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
tag="${GITHUB_REF_NAME}"
if [[ "${tag}" != "${expected_tag}" ]]; then
echo "Tag ${tag} does not match src-tauri version ${version}" >&2
exit 1
fi
else
tag="${expected_tag}"
fi
if [[ "${version}" == *-* ]]; then
prerelease=true
else
prerelease=false
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
echo "prerelease=${prerelease}" >> "${GITHUB_OUTPUT}"
frontend-assets:
runs-on: ubuntu-24.04
env:
CARGO_TERM_COLOR: always
NO_COLOR: "false"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Add cargo bin directory to PATH
shell: bash
run: echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install Rust toolchain
shell: bash
run: |
set -euo pipefail
rustup toolchain install stable --allow-downgrade
rustup default stable
rustup target add wasm32-unknown-unknown
- name: Install frontend build dependencies
shell: bash
run: |
set -euo pipefail
cargo install --locked trunk
cargo install --locked wasm-bindgen-cli
npm install --global --save-exact esbuild
npm install --global tailwindcss
npm install --global --save-exact sass
- name: Build frontend assets
shell: bash
run: |
set -euo pipefail
NO_COLOR=false trunk build
- name: Upload frontend assets
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: src-ui/dist
if-no-files-found: error
build:
needs:
- prepare
- frontend-assets
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
os_name: linux
arch: x86_64
bundles: appimage,deb,rpm
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
os_name: linux
arch: arm64
bundles: appimage,deb,rpm
- runner: macos-15-intel
target: x86_64-apple-darwin
os_name: macos
arch: x86_64
bundles: dmg
artifact_name: macos-x86_64
- runner: macos-15
target: aarch64-apple-darwin
os_name: macos
arch: arm64
bundles: dmg
artifact_name: macos-arm64
- runner: windows-2025
target: x86_64-pc-windows-msvc
os_name: windows
arch: x86_64
bundles: ""
artifact_name: windows-x86_64
- runner: windows-11-arm
target: aarch64-pc-windows-msvc
os_name: windows
arch: arm64
bundles: ""
artifact_name: windows-arm64
runs-on: ${{ matrix.runner }}
env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
NO_COLOR: "false"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Add cargo bin directory to PATH
shell: bash
run: echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install Rust toolchain
shell: bash
run: |
set -euo pipefail
rustup toolchain install stable --allow-downgrade
rustup default stable
rustup target add wasm32-unknown-unknown "${{ matrix.target }}"
- name: Install Linux build dependencies
if: startsWith(matrix.runner, 'ubuntu-')
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
pkg-config \
libssl-dev \
libfuse2t64 \
rpm
- name: Install README build dependencies
shell: bash
run: |
set -euo pipefail
cargo install tauri-cli --version "^2.0.0" --locked
cargo install --locked trunk
cargo install --locked wasm-bindgen-cli
npm install --global --save-exact esbuild
npm install --global tailwindcss
- name: Fetch Cargo dependencies
shell: bash
run: |
set -euo pipefail
cargo fetch
- name: Download frontend assets
if: matrix.os_name == 'windows'
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: src-ui/dist
- name: Build release bundles
shell: bash
run: |
set -euo pipefail
if [[ "${{ matrix.os_name }}" == "windows" ]]; then
cargo tauri build --ci --no-sign --no-bundle --target "${{ matrix.target }}" --config '{"build":{"beforeBuildCommand":""}}'
else
cargo tauri build --ci --no-sign --bundles "${{ matrix.bundles }}" --target "${{ matrix.target }}"
fi
- name: Stage release artifacts
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
OS_NAME: ${{ matrix.os_name }}
ARCH: ${{ matrix.arch }}
TARGET: ${{ matrix.target }}
run: |
set -euo pipefail
bundle_dir="target/${TARGET}/release/bundle"
stage_dir="ci-dist"
mkdir -p "${stage_dir}"
case "${OS_NAME}" in
linux)
cp "${bundle_dir}/appimage/"*.AppImage "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.AppImage"
cp "${bundle_dir}/deb/"*.deb "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.deb"
cp "${bundle_dir}/rpm/"*.rpm "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.rpm"
;;
macos)
cp "${bundle_dir}/dmg/"*.dmg "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.dmg"
;;
windows)
cp "target/${TARGET}/release/src_tauri.exe" "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.exe"
;;
*)
echo "Unsupported OS ${OS_NAME}" >&2
exit 1
;;
esac
- name: Upload staged artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os_name }}-${{ matrix.arch }}
path: ci-dist/*
if-no-files-found: error
- name: Upload Linux AppImage artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-appimage-${{ matrix.arch }}
path: ci-dist/*.AppImage
if-no-files-found: error
- name: Upload Linux deb artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-deb-${{ matrix.arch }}
path: ci-dist/*.deb
if-no-files-found: error
- name: Upload Linux rpm artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-rpm-${{ matrix.arch }}
path: ci-dist/*.rpm
if-no-files-found: error
publish:
needs:
- prepare
- build
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ needs.prepare.outputs.version }}
TAG: ${{ needs.prepare.outputs.tag }}
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
steps:
- name: Download staged artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create or update GitHub Release
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
files=()
while IFS= read -r file; do
files+=("${file}")
done < <(find dist -maxdepth 1 -type f | sort)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No release files found" >&2
exit 1
fi
if gh release view "${TAG}" >/dev/null 2>&1; then
gh release upload "${TAG}" "${files[@]}" --clobber
else
prerelease_flag=()
if [[ "${PRERELEASE}" == "true" ]]; then
prerelease_flag+=(--prerelease)
fi
gh release create "${TAG}" "${files[@]}" \
--title "WriterMD v${VERSION}" \
--generate-notes \
"${prerelease_flag[@]}"
fi