-
-
Notifications
You must be signed in to change notification settings - Fork 260
299 lines (264 loc) · 9.47 KB
/
Copy pathrelease.yml
File metadata and controls
299 lines (264 loc) · 9.47 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to (re)build (e.g. v2.0.0-beta.4)'
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.event.inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
prepare:
name: Prepare release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.context.outputs.tag }}
version: ${{ steps.context.outputs.version }}
is_prerelease: ${{ steps.context.outputs.is_prerelease }}
steps:
- name: Resolve tag and version
id: context
shell: bash
run: |
tag="${{ github.event.inputs.tag || github.ref_name }}"
if [[ "$tag" != v* ]]; then
echo "::error::Tag '$tag' must start with 'v'"
exit 1
fi
version="${tag#v}"
if [[ "$version" == *-* ]]; then
is_prerelease=true
else
is_prerelease=false
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "is_prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: ${{ steps.context.outputs.tag }}
fetch-depth: 0
- name: Verify package.json version matches tag
shell: bash
env:
EXPECTED: ${{ steps.context.outputs.version }}
run: |
actual=$(node -p "require('./package.json').version")
if [[ "$actual" != "$EXPECTED" ]]; then
echo "::error::package.json version ($actual) does not match tag version ($EXPECTED)"
exit 1
fi
- name: Ensure draft release exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
TAG: ${{ steps.context.outputs.tag }}
VERSION: ${{ steps.context.outputs.version }}
IS_PRERELEASE: ${{ steps.context.outputs.is_prerelease }}
shell: bash
run: |
previous_tag=""
while read -r candidate_tag; do
if [[ "$candidate_tag" == "$TAG" ]]; then
break
fi
previous_tag="$candidate_tag"
done < <(git tag --list 'v[0-9]*' --sort=v:refname)
notes_args=(-f "tag_name=$TAG" -f "target_commitish=$TAG")
if [[ -n "$previous_tag" ]]; then
notes_args+=(-f "previous_tag_name=$previous_tag")
fi
generated_notes_file="$(mktemp)"
gh api "repos/$REPOSITORY/releases/generate-notes" "${notes_args[@]}" --jq '.body // ""' \
| awk '!/^\*\*Full Changelog\*\*: /' > "$generated_notes_file"
notes_marker="<!-- generated-release-notes:$TAG -->"
release_notes_file="$(mktemp)"
{
echo "$notes_marker"
cat "$generated_notes_file"
} > "$release_notes_file"
if ! gh release view "$TAG" >/dev/null 2>&1; then
flags=(--draft)
if [[ "$IS_PRERELEASE" == "true" ]]; then
flags+=(--prerelease)
fi
gh release create "$TAG" \
--title "Sigma File Manager v$VERSION" \
--notes-file "$release_notes_file" \
"${flags[@]}"
else
existing_notes_file="$(mktemp)"
cleaned_notes_file="$(mktemp)"
updated_notes_file="$(mktemp)"
gh release view "$TAG" --json body --jq '.body // ""' > "$existing_notes_file"
awk '!/^\*\*Full Changelog\*\*: /' "$existing_notes_file" > "$cleaned_notes_file"
if grep -Fq "$notes_marker" "$cleaned_notes_file"; then
cp "$cleaned_notes_file" "$updated_notes_file"
elif [[ -s "$cleaned_notes_file" ]]; then
{
cat "$cleaned_notes_file"
echo
cat "$release_notes_file"
} > "$updated_notes_file"
else
cp "$release_notes_file" "$updated_notes_file"
fi
gh release edit "$TAG" --notes-file "$updated_notes_file"
echo "Release $TAG already exists; assets will be added/replaced."
fi
build:
name: Build (${{ matrix.platform }})
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- platform: windows
os: windows-latest
- platform: linux
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- name: Setup Volta
uses: volta-cli/action@v4
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust
shared-key: release-${{ matrix.platform }}
workspaces: src-tauri
cache-on-failure: true
- name: Resolve npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
- name: Cache npm
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf
- name: Install npm dependencies
run: npm ci
- name: Sync Cargo version with package.json
run: npm run sync-version
- name: Build Tauri bundles
env:
NO_STRIP: ${{ matrix.platform == 'linux' && 'true' || '' }}
PLATFORM: ${{ matrix.platform }}
shell: bash
run: |
if [[ "$PLATFORM" == "linux" ]]; then
npm run tauri:build:linux
else
npm run tauri:build
fi
- name: Upload Tauri bundles
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.prepare.outputs.tag }}
VERSION: ${{ needs.prepare.outputs.version }}
PLATFORM: ${{ matrix.platform }}
shell: bash
run: |
mkdir -p staged
shopt -s nullglob
if [[ "$PLATFORM" == "windows" ]]; then
bundles=(src-tauri/target/release/bundle/nsis/*.exe)
else
bundles=(
src-tauri/target/release/bundle/appimage/*.AppImage
src-tauri/target/release/bundle/deb/*.deb
)
fi
if (( ${#bundles[@]} == 0 )); then
echo "::error::No Tauri bundles found for $PLATFORM"
exit 1
fi
for bundle in "${bundles[@]}"; do
case "$bundle" in
*.AppImage)
staged_asset="staged/Sigma-File-Manager-${VERSION}-linux.AppImage"
;;
*.deb)
staged_asset="staged/Sigma-File-Manager-${VERSION}-linux.deb"
;;
*.exe)
staged_asset="staged/Sigma-File-Manager-${VERSION}-windows-setup.exe"
;;
*)
extension="${bundle##*.}"
staged_asset="staged/Sigma-File-Manager-${VERSION}-${PLATFORM}.${extension}"
;;
esac
cp "$bundle" "$staged_asset"
gh release upload "$TAG" "$staged_asset" --clobber
done
- name: Upload Linux binary
if: matrix.platform == 'linux'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.prepare.outputs.tag }}
VERSION: ${{ needs.prepare.outputs.version }}
shell: bash
run: |
binary="src-tauri/target/release/sigma-file-manager"
if [[ ! -f "$binary" ]]; then
echo "::error::Linux binary not found at $binary"
exit 1
fi
chmod +x "$binary"
mkdir -p staged
staged_binary="staged/Sigma-File-Manager-${VERSION}-linux-binary"
cp "$binary" "$staged_binary"
gh release upload "$TAG" "$staged_binary" --clobber
- name: Install Flatpak toolchain
if: matrix.platform == 'linux'
run: |
sudo apt-get install -y flatpak flatpak-builder
flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y --noninteractive --user flathub org.gnome.Platform//48 org.gnome.Sdk//48
- name: Build Flatpak bundle
if: matrix.platform == 'linux'
run: bash flatpak/build-flatpak.sh
- name: Upload Flatpak bundle
if: matrix.platform == 'linux'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.prepare.outputs.tag }}
VERSION: ${{ needs.prepare.outputs.version }}
shell: bash
run: |
flatpak_bundle="flatpak/output/Sigma-File-Manager-${VERSION}-linux.flatpak"
if [[ ! -f "$flatpak_bundle" ]]; then
echo "::error::Flatpak bundle not found at $flatpak_bundle"
exit 1
fi
gh release upload "$TAG" "$flatpak_bundle" --clobber