-
Notifications
You must be signed in to change notification settings - Fork 12
220 lines (209 loc) · 7.66 KB
/
release.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
name: 'publish'
on:
push:
tags:
- 'v*'
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-20.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
release_note: ${{ steps.release-note.outputs.release_note }}
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: get version
id: get-version
run: |
echo "PACKAGE_VERSION=$(node -p "\"${{ github.ref_name }}\".slice(1)")" >> $GITHUB_ENV
echo "version=$(node -p "\"${{ github.ref_name }}\".slice(1)")" >> $GITHUB_OUTPUT
- name: get release note
id: release-note
run: |
release_note=$(cat ${{ github.workspace }}/RELEASE_NOTE.md)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "RELEASE_NOTE<<$EOF" >> $GITHUB_ENV
echo "$release_note" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
release_note="${release_note//'%'/'%25'}"
release_note="${release_note//$'\n'/'%0A'}"
release_note="${release_note//$'\r'/'%0D'}"
echo "release_note=$release_note" >> $GITHUB_OUTPUT
- name: create release
id: create-release
uses: actions/github-script@v6
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: `ChatWizard v${process.env.PACKAGE_VERSION}`,
body: `${process.env.RELEASE_NOTE}`,
draft: true,
prerelease: false
})
return data.id
build:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: x86_64-apple-darwin
- platform: macos-latest
target: aarch64-apple-darwin
- platform: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- platform: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- 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 target (macos aarch64 only)
if: matrix.target == 'aarch64-apple-darwin'
run: |
rustup target add aarch64-apple-darwin
- name: install frontend dependencies
run: npm i -g pnpm && cd web && pnpm install
- uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ''
with:
projectPath: gui
args: --target ${{ matrix.target }}
releaseId: ${{ needs.create-release.outputs.release_id }}
releaseBody: '${{ needs.create-release.outputs.release_note }}'
- name: build cli
run: |
cd cli
cargo build --release --target ${{ matrix.target }}
cd ..
- name: upload cli asset
if: matrix.platform == 'windows-latest'
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
version: ${{ needs.create-release.outputs.version }}
target: ${{ matrix.target }}
with:
script: |
const file = require('fs').readFileSync(`target/${process.env.target}/release/chat-wizard-cli.exe`)
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: `chat-wizard-cli_${process.env.target}.exe`,
data: file,
})
- name: upload cli asset
if: matrix.platform != 'windows-latest'
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
version: ${{ needs.create-release.outputs.version }}
target: ${{ matrix.target }}
with:
script: |
const file = require('fs').readFileSync(`target/${process.env.target}/release/chat-wizard-cli`)
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: `chat-wizard-cli_${process.env.target}`,
data: file,
})
- name: build server
run: |
cd server
cargo build --release --target ${{ matrix.target }}
cd ..
- name: upload server asset
if: matrix.platform == 'windows-latest'
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
version: ${{ needs.create-release.outputs.version }}
target: ${{ matrix.target }}
with:
script: |
const file = require('fs').readFileSync(`target/${process.env.target}/release/chat-wizard-server.exe`)
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: `chat-wizard-server_${process.env.target}.exe`,
data: file,
})
- name: upload server asset
if: matrix.platform != 'windows-latest'
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
version: ${{ needs.create-release.outputs.version }}
target: ${{ matrix.target }}
with:
script: |
const file = require('fs').readFileSync(`target/${process.env.target}/release/chat-wizard-server`)
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: `chat-wizard-server_${process.env.target}`,
data: file,
})
publish-release:
permissions:
contents: write
runs-on: ubuntu-20.04
needs: [create-release, build]
steps:
- name: publish release
id: publish-release
uses: actions/github-script@v6
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
})
updater:
runs-on: ubuntu-latest
needs: [build, publish-release]
steps:
- uses: actions/checkout@v3
- run: |
mkdir -p ${{ github.workspace }}/docs
wget -O ${{ github.workspace }}/docs/latest.json https://github.com/lisiur/ChatWizard/releases/download/${{ github.ref_name }}/latest.json
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
publish_dir: ./docs