Repository navigation
163 lines (140 loc) · 5.91 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (140 loc) · 5.91 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:
branches:
- main
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
name: Resolve release version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.release-version.outputs.version }}
steps:
- name: Checkout repository and tags
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: lts/*
- name: Resolve release version
id: release-version
shell: bash
run: |
VERSION="$(node scripts/release-version.mjs next)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Release version: $VERSION"
publish:
name: Build and publish (${{ matrix.platform }} ${{ matrix.targetName }})
needs: prepare
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
targetName: macOS Apple Silicon
args: --target aarch64-apple-darwin
- platform: macos-latest
targetName: macOS Intel
args: --target x86_64-apple-darwin
- platform: ubuntu-22.04
targetName: Linux x64
args: ""
- platform: windows-latest
targetName: Windows x64
args: ""
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: lts/*
cache: npm
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Set release version
run: node scripts/release-version.mjs set "${{ needs.prepare.outputs.version }}"
- name: Cache Rust build artifacts
uses: swatinem/rust-cache@v2
with:
workspaces: ./src-tauri -> target
- name: Install frontend dependencies
run: npm ci
- name: Build and publish Tauri app
uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: wordsnap-v__VERSION__
releaseName: WordSnap v__VERSION__
releaseBody: |
本版本由提交 ${{ github.sha }} 自动构建并发布。
请根据运行平台选择相应产物。多数用户可以使用免安装版本:
- macOS Apple Silicon:`WordSnap_<版本>_macos-aarch64_portable.zip`
- macOS Intel:`WordSnap_<版本>_macos-x64_portable.zip`
解压后运行 `WordSnap.app`。当前应用未签名。如果首次启动被 Gatekeeper 阻止,可以右键单击应用并选择打开,或在终端执行 `xattr -cr WordSnap.app` 后重新启动。
- Windows x64:`WordSnap_<版本>_windows-x64_portable.zip`
解压后运行 `WordSnap.exe`。应用依赖系统中的 WebView2 运行时,Windows 10 和 Windows 11 通常已经包含该运行时。
- Linux x64:`*.AppImage`
下载后执行 `chmod +x WordSnap_*.AppImage`,随后直接运行该文件。
如需使用安装程序,可以下载相应的 `.dmg`、`.msi`、NSIS `.exe`、`.deb` 或 `.rpm` 文件。
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}
- name: Package portable macOS app (Apple Silicon)
if: matrix.platform == 'macos-latest' && contains(matrix.args, 'aarch64-apple-darwin')
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="$(node -p "require('./src-tauri/tauri.conf.json').version")"
TAG="wordsnap-v${VERSION}"
APP_PATH="src-tauri/target/aarch64-apple-darwin/release/bundle/macos/WordSnap.app"
ZIP_NAME="WordSnap_${VERSION}_macos-aarch64_portable.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "$ZIP_NAME"
gh release upload "$TAG" "$ZIP_NAME" --clobber
- name: Package portable macOS app (Intel)
if: matrix.platform == 'macos-latest' && contains(matrix.args, 'x86_64-apple-darwin')
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="$(node -p "require('./src-tauri/tauri.conf.json').version")"
TAG="wordsnap-v${VERSION}"
APP_PATH="src-tauri/target/x86_64-apple-darwin/release/bundle/macos/WordSnap.app"
ZIP_NAME="WordSnap_${VERSION}_macos-x64_portable.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "$ZIP_NAME"
gh release upload "$TAG" "$ZIP_NAME" --clobber
- name: Package portable Windows app
if: matrix.platform == 'windows-latest'
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$version = node -p "require('./src-tauri/tauri.conf.json').version"
$tag = "wordsnap-v$version"
$releaseDir = "src-tauri/target/release"
$exe = Get-ChildItem -Path $releaseDir -Filter *.exe -File |
Where-Object { $_.Name -notlike '*setup*' -and $_.Name -notlike '*installer*' } |
Select-Object -First 1
if (-not $exe) { throw "No portable exe found in $releaseDir" }
Write-Host "Found portable exe: $($exe.FullName)"
$zipName = "WordSnap_${version}_windows-x64_portable.zip"
Compress-Archive -Path $exe.FullName -DestinationPath $zipName -Force
gh release upload $tag $zipName --clobber