-
Notifications
You must be signed in to change notification settings - Fork 26
113 lines (95 loc) · 3.73 KB
/
snap.yml
File metadata and controls
113 lines (95 loc) · 3.73 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
name: Build Snap Package
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.11.0)'
required: true
default: 'v1.11.0'
jobs:
build-snap:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Get version
id: get-version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install frontend dependencies
working-directory: open-pdf-studio
run: npm install
- name: Build Tauri app
working-directory: open-pdf-studio
run: npx tauri build
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: 'tauri2026'
- name: Prepare snap build
run: |
# Find the built deb
DEB_FILE=$(find open-pdf-studio/src-tauri/target/release/bundle/deb -name "*.deb" | head -1)
echo "Found deb: $DEB_FILE"
# Copy deb to repo root for snapcraft
cp "$DEB_FILE" open-pdf-studio.deb
# Update version in snapcraft.yaml
sed -i "s/^version: .*/version: '${{ steps.get-version.outputs.version_number }}'/" snap/snapcraft.yaml
- name: Install Snapcraft
run: sudo snap install snapcraft --classic
- name: Build snap
id: snapcraft
run: |
# Use destructive mode so snapcraft builds directly on the runner
# instead of spinning up an LXD container. The default LXD provider
# fails on GitHub Actions runners because the runner user isn't in
# the `lxd` group and snapcraft can't add it on the fly. Destructive
# mode is the standard pattern for ephemeral CI environments.
# `snapcraft pack` replaces the bare `snapcraft` invocation which
# is deprecated in snapcraft 8+.
sudo snapcraft pack --destructive-mode
SNAP_FILE=$(ls *.snap | head -1)
echo "snap=$SNAP_FILE" >> $GITHUB_OUTPUT
echo "Built snap: $SNAP_FILE"
- name: Upload snap to GitHub release
run: |
SNAP_FILE="${{ steps.snapcraft.outputs.snap }}"
echo "Uploading $SNAP_FILE to release ${{ steps.get-version.outputs.version }}"
# Wait for the release to be created by the main release workflow
for i in $(seq 1 30); do
if gh release view "${{ steps.get-version.outputs.version }}" > /dev/null 2>&1; then
echo "Release found"
break
fi
echo "Waiting for release... (attempt $i/30)"
sleep 30
done
gh release upload "${{ steps.get-version.outputs.version }}" "$SNAP_FILE" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Snap Store
if: env.SNAPCRAFT_STORE_CREDENTIALS != ''
run: |
SNAP_FILE="${{ steps.snapcraft.outputs.snap }}"
snapcraft upload "$SNAP_FILE" --release=stable
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}