-
Notifications
You must be signed in to change notification settings - Fork 30
229 lines (197 loc) · 6.88 KB
/
publish.yml
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
name: "publish"
on:
push:
branches:
- release
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-22.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
package_version: ${{ env.PACKAGE_VERSION }}
latest_version: ${{ steps.latest-version.outputs.result }}
changelog: ${{ steps.github_release_changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: get version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: check latest version
uses: actions/github-script@v7
id: latest-version
with:
script: |
const { data } = await github.request(
'GET /repos/{owner}/{repo}/releases/latest',
{
owner: context.repo.owner,
repo: context.repo.repo,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
}
)
const latesVersion = data.tag_name.slice(1)
if (latesVersion === process.env.PACKAGE_VERSION) throw new Error("当前要发布的版本号与 latest 版本号相同")
return latesVersion
- name: build changelog
id: github_release_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: ".github/changelog-configuration.json"
toTag: "refs/heads/main"
failOnError: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create release
id: create-release
uses: actions/github-script@v7
env:
changelog: ${{ steps.github_release_changelog.outputs.changelog }}
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${process.env.PACKAGE_VERSION}`,
name: `v${process.env.PACKAGE_VERSION}`,
body: process.env.changelog,
draft: true,
prerelease: process.env.PACKAGE_VERSION.indexOf('alpha') >= 0,
})
return data.id
build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest"
args: "--target aarch64-apple-darwin"
- platform: "macos-latest"
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04"
args: ""
- platform: "windows-latest"
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: oven-sh/setup-bun@v1
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: install frontend dependencies
run: bun run install:all
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
releaseBody: ${{ needs.create-release.outputs.changelog }}
updaterJsonPreferNsis: true
args: ${{ matrix.args }}
publish-release:
permissions:
contents: write
runs-on: ubuntu-22.04
needs: [create-release, build-tauri]
steps:
- name: publish release
id: publish-release
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
PACKAGE_VERSION: ${{ needs.create-release.outputs.package_version }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
draft: false,
})
upload_mirror_json:
permissions:
contents: write
runs-on: ubuntu-22.04
needs: [create-release, publish-release]
env:
release_id: ${{ needs.create-release.outputs.release_id }}
steps:
- uses: actions/checkout@v4
- name: get latest.json
id: get-latest
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const assets = await github.rest.repos.listReleaseAssets({
owner: owner,
repo: repo,
release_id: process.env.release_id,
per_page: 50,
});
const asset = assets.data.find((e) => e.name === 'latest.json');
if (!asset) throw new Error("latest.json was not found in release assets");
const data = await github.request(
"GET /repos/{owner}/{repo}/releases/assets/{asset_id}",
{
owner: owner,
repo: repo,
asset_id: asset.id,
headers: {
accept: "application/octet-stream",
},
},
);
return Buffer.from(data.data).toString()
- name: new mirror latest.json
env:
TEXT: ${{ steps.get-latest.outputs.result }}
run: |
cd .scripts
node mirror-latest-json.js
- uses: wlixcc/[email protected]
with:
username: thepoy
server: thepoy.cc
password: ${{ secrets.TAURI_KEY_PASSWORD }}
local_path: ./.scripts/mirrors/*
remote_path: /home/thepoy/app/alley-transfer
sftpArgs: "-o ConnectTimeout=5"
delete-nightly-release-and-tag:
permissions:
contents: write
runs-on: ubuntu-22.04
needs: upload_mirror_json
steps:
- uses: actions/checkout@v4
- name: get old nightly release id
run: |
release_id=$(curl -s 'https://api.github.com/repos/alley-rs/lsar/releases/tags/nightly' | awk -F'[{},:]+' '/^ "id"/ {print $2}' | xargs)
echo "RELEASE_ID=$release_id" >> $GITHUB_ENV
- name: delete old nightly release
if: env.RELEASE_ID != ''
run: gh release delete nightly --cleanup-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}