Skip to content

Commit ec58637

Browse files
committed
ci: migrate Snap build and release to GitHub actions
- upgrade Snap base to core24 - drop ARM support for Linux
1 parent 11c84f0 commit ec58637

File tree

4 files changed

+173
-52
lines changed

4 files changed

+173
-52
lines changed

.changeset/many-hoops-say.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"zaku": patch
3+
---
4+
5+
Migrate snapcraft build & release to github actions
6+
7+
- Upgrade snap base to `core24`
8+
- Drop ARM support for linux

.github/workflows/pull_request.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,63 @@ jobs:
262262
uses: tauri-apps/tauri-action@v0
263263
with:
264264
args: ${{ matrix.args }}
265+
266+
build_snap_package:
267+
name: "Build Snap Package"
268+
if: github.repository == 'buildzaku/zaku'
269+
runs-on: ubuntu-latest
270+
steps:
271+
- name: "Checkout repository"
272+
uses: actions/checkout@v4
273+
274+
- name: "Setup pnpm"
275+
uses: pnpm/action-setup@v4
276+
with:
277+
version: ${{ env.PNPM_VERSION }}
278+
279+
- name: "Setup Node.js"
280+
uses: actions/setup-node@v4
281+
with:
282+
node-version: ${{ env.NODE_VERSION }}
283+
cache: pnpm
284+
285+
- name: "Get pnpm store directory"
286+
id: pnpm_cache
287+
shell: bash
288+
run: echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
289+
290+
- name: "Setup pnpm cache"
291+
uses: actions/cache@v4
292+
with:
293+
path: ${{ steps.pnpm_cache.outputs.pnpm_cache_dir }}
294+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
295+
restore-keys: ${{ runner.os }}-pnpm-store-
296+
297+
- name: "Setup Rust"
298+
uses: dtolnay/rust-toolchain@stable
299+
300+
- name: "Setup Rust cache"
301+
uses: swatinem/rust-cache@v2
302+
with:
303+
workspaces: "./src-tauri -> target"
304+
305+
- name: "Install system dependencies"
306+
run: |
307+
sudo apt-get update
308+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev
309+
310+
- name: "Install frontend dependencies"
311+
run: pnpm install
312+
313+
- name: "Build application"
314+
run: pnpm tauri build --bundles deb
315+
316+
- name: "Extract .deb to snap-stage/"
317+
run: |
318+
mkdir -p snap-stage
319+
dpkg -x src-tauri/target/release/bundle/deb/*.deb snap-stage/
320+
sed -i -e "s|Icon=zaku|Icon=/usr/share/icons/hicolor/32x32/apps/zaku.png|g" snap-stage/usr/share/applications/Zaku.desktop
321+
322+
- name: "Build Snap package"
323+
uses: snapcore/action-build@v1
324+
id: build

.github/workflows/release.yml

Lines changed: 97 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
- main
77
workflow_dispatch:
88
inputs:
9-
force_upload_or_reupload_assets:
10-
description: "Force upload/re-upload assets."
9+
force_release_build_assets:
10+
description: "Force run release_build_assets"
11+
type: boolean
12+
default: false
13+
required: false
14+
force_build_and_publish_snap:
15+
description: "Force run build_and_publish_snap"
1116
type: boolean
1217
default: false
1318
required: false
@@ -28,6 +33,7 @@ jobs:
2833
runs-on: ubuntu-latest
2934
outputs:
3035
is_published: ${{ steps.changesets.outputs.published }}
36+
version: ${{ steps.new_version.outputs.value }}
3137
steps:
3238
- name: "Checkout repository"
3339
uses: actions/checkout@v4
@@ -90,10 +96,10 @@ jobs:
9096
env:
9197
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9298

93-
release_builds:
94-
name: "Release Builds"
99+
release_build_assets:
100+
name: "Release Build Assets"
95101
needs: [version_or_publish]
96-
if: ${{ github.repository == 'buildzaku/zaku' && (needs.version_or_publish.outputs.is_published == 'true' || github.event.inputs.force_upload_or_reupload_assets == 'true') }}
102+
if: ${{ github.repository == 'buildzaku/zaku' && (needs.version_or_publish.outputs.is_published == 'true' || github.event.inputs.force_release_build_assets == 'true') }}
97103
permissions:
98104
contents: "write"
99105
strategy:
@@ -159,11 +165,96 @@ jobs:
159165
- name: "Install frontend dependencies"
160166
run: pnpm install
161167

162-
- name: "Create release builds"
168+
- name: "Build and upload artifacts"
163169
uses: tauri-apps/tauri-action@v0
164170
env:
165171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166172
with:
167173
tagName: "v__VERSION__"
168174
releaseName: "v__VERSION__"
169175
args: ${{ matrix.args }}
176+
177+
build_and_publish_snap:
178+
name: "Build & Publish Snap"
179+
needs: [version_or_publish]
180+
if: ${{ github.repository == 'buildzaku/zaku' && (needs.version_or_publish.outputs.is_published == 'true' || github.event.inputs.force_build_and_publish_snap == 'true') }}
181+
runs-on: ubuntu-latest
182+
steps:
183+
- name: "Checkout repository"
184+
uses: actions/checkout@v4
185+
186+
- name: "Setup pnpm"
187+
uses: pnpm/action-setup@v4
188+
with:
189+
version: ${{ env.PNPM_VERSION }}
190+
191+
- name: "Setup Node.js"
192+
uses: actions/setup-node@v4
193+
with:
194+
node-version: ${{ env.NODE_VERSION }}
195+
cache: pnpm
196+
197+
- name: "Get pnpm store directory"
198+
id: pnpm_cache
199+
shell: bash
200+
run: echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
201+
202+
- name: "Setup pnpm cache"
203+
uses: actions/cache@v4
204+
with:
205+
path: ${{ steps.pnpm_cache.outputs.pnpm_cache_dir }}
206+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
207+
restore-keys: ${{ runner.os }}-pnpm-store-
208+
209+
- name: "Setup Rust"
210+
uses: dtolnay/rust-toolchain@stable
211+
212+
- name: "Setup Rust cache"
213+
uses: swatinem/rust-cache@v2
214+
with:
215+
workspaces: "./src-tauri -> target"
216+
217+
- name: "Install system dependencies"
218+
run: |
219+
sudo apt-get update
220+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev
221+
222+
- name: "Install frontend dependencies"
223+
run: pnpm install
224+
225+
- name: "Build application"
226+
run: pnpm tauri build --bundles deb
227+
228+
- name: "Extract .deb to snap-stage/"
229+
run: |
230+
mkdir -p snap-stage
231+
dpkg -x src-tauri/target/release/bundle/deb/*.deb snap-stage/
232+
sed -i -e "s|Icon=zaku|Icon=/usr/share/icons/hicolor/32x32/apps/zaku.png|g" snap-stage/usr/share/applications/Zaku.desktop
233+
234+
- name: "Set Snap release channel"
235+
id: snap_channel
236+
shell: bash
237+
run: |
238+
VERSION="${{ needs.version_or_publish.outputs.version }}"
239+
240+
if [[ "$VERSION" == *"-alpha."* ]]; then
241+
echo "channel=edge" >> $GITHUB_OUTPUT
242+
elif [[ "$VERSION" == *"-beta."* ]]; then
243+
echo "channel=beta" >> $GITHUB_OUTPUT
244+
elif [[ "$VERSION" == *"-rc."* ]]; then
245+
echo "channel=candidate" >> $GITHUB_OUTPUT
246+
else
247+
echo "channel=stable" >> $GITHUB_OUTPUT
248+
fi
249+
250+
- name: "Build Snap package"
251+
uses: snapcore/action-build@v1
252+
id: build
253+
254+
- name: "Publish to Snap Store"
255+
uses: snapcore/action-publish@v1
256+
env:
257+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
258+
with:
259+
snap: ${{ steps.build.outputs.snap }}
260+
release: ${{ steps.snap_channel.outputs.channel }}

snapcraft.yaml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,27 @@
11
name: zaku
2-
base: core22
2+
base: core24
33
version: 0.5.0
44
summary: Fast, open-source API client with fangs
55
description: |
66
Fast, open-source API client with fangs
77
grade: stable
88
confinement: strict
9-
architectures:
10-
- build-on:
11-
- amd64
12-
build-for:
13-
- amd64
14-
- build-on:
15-
- arm64
16-
build-for:
17-
- arm64
9+
10+
platforms:
11+
amd64:
12+
1813
apps:
1914
zaku:
2015
command: usr/bin/zaku
2116
desktop: usr/share/applications/Zaku.desktop
2217
plugs:
2318
- network
24-
environment:
25-
LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$LD_LIBRARY_PATH"
26-
PKG_CONFIG_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig:$PKG_CONFIG_PATH"
27-
CFLAGS: "-I$SNAP/usr/include"
28-
LDFLAGS: "-L$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET"
19+
2920
parts:
30-
build-app:
21+
app:
3122
plugin: dump
32-
build-snaps:
33-
- node/22/stable
34-
- rustup/latest/stable
35-
build-packages:
36-
- libwebkit2gtk-4.1-dev
37-
- build-essential
38-
- curl
39-
- wget
40-
- file
41-
- libxdo-dev
42-
- libssl-dev
43-
- libayatana-appindicator3-dev
44-
- librsvg2-dev
45-
- dpkg
46-
- libasound2-dev
47-
- libglib2.0-dev
23+
source: snap-stage
4824
stage-packages:
4925
- libwebkit2gtk-4.1-0
5026
- libayatana-appindicator3-1
5127
- libasound2
52-
source: .
53-
override-build: |
54-
set -eu
55-
56-
rustup default stable
57-
58-
npm install -g [email protected]
59-
export PATH="$HOME/.npm-global/bin:$PATH"
60-
61-
pnpm install
62-
pnpm tauri build --bundles deb
63-
64-
dpkg -x src-tauri/target/release/bundle/deb/*.deb $SNAPCRAFT_PART_INSTALL/
65-
sed -i -e "s|Icon=zaku|Icon=/usr/share/icons/hicolor/32x32/apps/zaku.png|g" $SNAPCRAFT_PART_INSTALL/usr/share/applications/Zaku.desktop

0 commit comments

Comments
 (0)