-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (168 loc) · 5.77 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
name: publish
on:
push:
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
- run: npm install
- name: run tests
run: npm test
create-release:
needs: run-tests
permissions:
contents: write
runs-on: ubuntu-20.04
outputs:
release-id: ${{ steps.create-release.outputs.result }}
version: ${{ steps.get-next-version.outputs.new-release-version }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- run: npx semantic-release --dry-run
id: get-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get version
run: echo "PACKAGE_VERSION=${{ steps.get-next-version.outputs.new-release-version }}" >> $GITHUB_ENV
- name: get changelog
env:
NOTES: ${{ steps.get-next-version.outputs.new-release-notes }}
run: |
CHANGELOG=$(echo "$NOTES" | tail -n +3)
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: create release
id: create-release
uses: actions/github-script@v7
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: `Kuwaka Wakati v${process.env.PACKAGE_VERSION}`,
body: `${process.env.CHANGELOG}`,
draft: true,
prerelease: false
})
return data.id
build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [ macos-latest, ubuntu-20.04, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: update package.json with current version
uses: jaywcjlove/github-action-package@main
with:
version: ${{ needs.create-release.outputs.version }}
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.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: npm install
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE_DATA }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE_DATA }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSPHRASE }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_TEAM_NAME }}
APPLE_ID: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
APPLE_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release-id }}
args: --verbose
publish-release:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-20.04
needs: [ create-release, build-tauri ]
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: install frontend dependencies
run: npm install
- run: npx semantic-release
id: get-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: publish release
id: publish-release
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release-id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
draft: false,
prerelease: false
})
- name: download latest.json for the updater
id: latest-json
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release-id }}
with:
result-encoding: string
script: |
const result = await github.rest.repos.getRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id
});
const latestJson = result.data.assets.find(asset => asset.name === 'latest.json');
if (!latestJson) {
throw new Error('latest.json not found.');
}
const latestJsonContent = await github.request(latestJson.browser_download_url);
const textDecoder = new TextDecoder('utf-8');
return textDecoder.decode(latestJsonContent.data);
- name: Deploy update.json to Gist
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GIST_TOKEN }}
script: |
github.rest.gists.update({
gist_id: 'c65aab8be88bbbb49f82b1d060e26e52',
files: {
'update.json': {
content: `${{ steps.latest-json.outputs.result }}`
}
}
})