-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (141 loc) · 5.48 KB
/
release.yml
File metadata and controls
163 lines (141 loc) · 5.48 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
name: release
on:
push:
tags:
- "v*"
env:
BIN_NAME: mnemonic-hasher
jobs:
version-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify versions match tag
run: |
python - <<'PY'
import json, os, sys, re, pathlib
try:
import tomllib # Python 3.11+ on ubuntu-latest
except Exception as e:
print("Python >=3.11 required for tomllib", file=sys.stderr)
sys.exit(2)
tag = os.environ.get("GITHUB_REF_NAME","")
if not tag:
print("GITHUB_REF_NAME not set; are we on a tag ref?", file=sys.stderr)
sys.exit(2)
# Accept tags like v1.2.3 or 1.2.3 (keeps the numeric part)
m = re.fullmatch(r'v?(\d+\.\d+\.\d+(?:[-+].*)?)', tag)
if not m:
print(f"Tag '{tag}' doesn't look like a semver (vMAJOR.MINOR.PATCH[prerelease+build])", file=sys.stderr)
sys.exit(2)
tagver = m.group(1)
root = pathlib.Path(".")
errors = []
# package.json
pkg_path = root / "package.json"
try:
pkgver = json.loads(pkg_path.read_text())["version"]
except Exception as e:
print(f"Failed reading version from {pkg_path}: {e}", file=sys.stderr); sys.exit(2)
# tauri.conf.json (either at repo root or under src-tauri/)
tauri_path = root / "tauri.conf.json"
if not tauri_path.exists():
tauri_path = root / "src-tauri" / "tauri.conf.json"
try:
tauri = json.loads(tauri_path.read_text())
# Tauri can store version at package.version or top-level version
tauriver = (tauri.get("package") or {}).get("version") or tauri.get("version")
except Exception as e:
print(f"Failed reading version from {tauri_path}: {e}", file=sys.stderr); sys.exit(2)
# src-tauri/Cargo.toml (typical Tauri layout)
cargo_path = root / "src-tauri" / "Cargo.toml"
try:
cargover = tomllib.loads(cargo_path.read_text())["package"]["version"]
except Exception as e:
print(f"Failed reading version from {cargo_path}: {e}", file=sys.stderr); sys.exit(2)
# Report and compare
print(f"git tag : {tagver}")
print(f"package.json : {pkgver}")
print(f"Cargo.toml : {cargover}")
print(f"tauri.conf.json: {tauriver}")
mismatches = []
for name, v in [("package.json", pkgver), ("Cargo.toml", cargover), ("tauri.conf.json", tauriver)]:
if v != tagver:
mismatches.append((name, v))
if mismatches:
print("\nVersion mismatch detected:", file=sys.stderr)
for n, v in mismatches:
print(f" - {n}: {v} != {tagver}", file=sys.stderr)
sys.exit(1)
else:
print("\nAll versions match the tag.")
PY
build:
name: build (${{ matrix.os }} ${{ matrix.args }})
needs: version-check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux (x86_64)
- os: ubuntu-22.04
args: ""
# Windows (x86_64)
- os: windows-latest
args: ""
# macOS (Apple Silicon)
- os: macos-latest
args: "--target aarch64-apple-darwin"
# macOS (Intel)
- os: macos-latest
args: "--target x86_64-apple-darwin"
steps:
- uses: actions/checkout@v4
# Install pnpm
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
version: 20
cache: "pnpm"
# Install Rust toolchain + target
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
# Install both mac targets on macOS runners so we can cross-build each job quickly.
targets: ${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Install Windows build deps
if: runner.os == 'Windows'
shell: powershell
run: choco install -y rsync
- name: Install Linux build deps
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
# Tauri v2 needs webkit2gtk 4.1; patchelf is needed by the bundler.
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf rsync
# Install dependencies
- name: Install pnpm dependencies
run: pnpm install --frozen-lockfile
- name: Build & publish with tauri-action
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Workarounds for linuxdeploy quirks when stripping/using FUSE:
NO_STRIP: "1" # avoids strip failures on libs with .relr.dyn
APPIMAGE_EXTRACT_AND_RUN: "1" # runs AppImages without FUSE
with:
# Let the action create/find the release for this tag and upload artifacts.
tagName: v__VERSION__
releaseName: "scriptorium v__VERSION__"
releaseBody: "See the assets to download this version."
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}
tauriScript: pnpm tauri
projectPath: .