-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (211 loc) · 7.23 KB
/
verify-publish.yaml
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
on:
pull_request:
push:
branches:
- master
name: Verify & Publish
jobs:
verify:
runs-on: ubuntu-20.04
steps:
- name: Check out
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Setup Cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: install cargo-fmt
run: rustup component add rustfmt
- name: install cargo-clippy
run: rustup component add clippy
- name: run cargo:fmt
run: cd src-tauri && cargo fmt --all -- --check
- name: generate ts bindings
run: cd src-tauri && cargo run -q -- generate-bindings --only
- name: install frontend dependencies
run: yarn install
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: run cargo:clippy
run: cd src-tauri && cargo clippy --all-features -- -D warnings
- name: setup Tarpaulin
run: cd src-tauri && cargo install cargo-tarpaulin
continue-on-error: true
- name: run cargo:tarpaulin (runs cargo test)
run: cd src-tauri && cargo tarpaulin --verbose --all-features --out Xml --output-dir ./coverage
- name: Codecov
uses: codecov/codecov-action@v3
with:
files: ./src-tauri/coverage/cobertura.xml
versioning:
permissions:
contents: write
needs: [ verify ]
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn install
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- uses: actions-rs/cargo@v1
with:
command: install
args: cargo-edit
- name: push & merge back to develop
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "actions@github.com"
git fetch --unshallow
yarn run release
VERSION=$(cat package.json | jq -r '.version')
git tag -d v$VERSION
(cd src-tauri && cargo set-version $VERSION)
(cd src-tauri && jq ".package.version = \"$VERSION\"" tauri.conf.json > tauri.conf.json.tmp && mv tauri.conf.json.tmp tauri.conf.json)
git commit --amend -am "chore(release): $VERSION"
git tag -a v$VERSION -m "chore(release): $VERSION"
git push --follow-tags origin master
git checkout develop
git pull
git merge master
git push
git checkout master
create-release:
needs: [ verify, versioning ]
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore(release):')
permissions:
contents: write
runs-on: ubuntu-20.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: pull latest commit
run: git pull
- name: get version & changelog
run: |
VERSION=$(node -p "require('./package.json').version")
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
echo 'CHANGELOG<<EOF' >> $GITHUB_ENV
echo "$(awk -v ver=$VERSION '
/^(##|###) \[?[0-9]+.[0-9]+.[0-9]+/ {
if (p) { exit };
if (index($2, "[")) {
split($2, a, "[");
split(a[2], a, "]");
if (a[1] == ver) {
p = 1
}
} else {
if ($2 == ver) {
p = 1
}
}
} p
' CHANGELOG.md)" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- 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: `huehuehue v${process.env.PACKAGE_VERSION}`,
body: `${process.env.CHANGELOG}`,
draft: true,
prerelease: false
})
return data.id
build-tauri:
needs: create-release
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore(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@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- 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: pull latest commit
run: git pull
- name: generate ts bindings
run: cd src-tauri && cargo run -q -- generate-bindings --only
- name: install frontend dependencies
run: yarn install
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
publish-release:
permissions:
contents: write
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-20.04
needs: [ create-release, build-tauri ]
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
})