-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (257 loc) · 10.2 KB
/
pipe.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: CI/CD
on:
push:
pull_request:
types:
- opened
workflow_dispatch: # allow manual execution
jobs:
check-repo:
name: Check git repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
format: 'table'
exit-code: '1'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
check-code-style:
name: Check code style
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
- uses: Swatinem/rust-cache@v2 # use /rust/cargo caching
with:
workspaces: "src-tauri -> target"
cache-on-failure: true # upload cache even if there are errors in this step
- name: Check the code style
run: cd src-tauri && cargo fmt --all -- --check
check-code:
name: Check rust code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: install dependencies
run: |
sudo apt update
sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev librsvg2-dev
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2 # use /rust/cargo caching
with:
workspaces: "src-tauri -> target"
cache-on-failure: true # upload cache even if there are errors in this step
- name: Verify code
run: cd src-tauri && cargo clippy
test:
name: Run application tests
runs-on: ubuntu-latest
env:
BIGDATA_CLOUD_API_KEY: ${{ secrets.BIGDATA_CLOUD_API_KEY }}
OPEN_WEATHER_MAP_API_KEY: ${{ secrets.OPEN_WEATHER_MAP_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: install dependencies
run: |
sudo apt update
sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev librsvg2-dev
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v2 # use /rust/cargo caching
with:
workspaces: "src-tauri -> target"
cache-on-failure: true # upload cache even if there are errors in this step
- name: Test code
run: cd src-tauri && cargo test
create-release:
name: Create new release
needs: [ check-repo, check-code-style, check-code, test ]
runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: |
npm install -g \
semantic-release \
@semantic-release/git \
@semantic-release/gitlab \
@semantic-release/changelog \
@semantic-release/exec \
@semantic-release/commit-analyzer \
conventional-changelog-conventionalcommits
- name: Generate Semantic Release Notes and Create Release
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: npx semantic-release
- name: Delete old releases
uses: dev-drprasad/[email protected]
with:
keep_latest: 5
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bundle-and-upload:
needs: [ create-release ]
name: Bundle and upload application artifacts
strategy:
fail-fast: false
matrix:
platform: [ ubuntu-20.04, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2 # use /rust/cargo caching
with:
workspaces: "src-tauri -> target"
cache-on-failure: true # upload cache even if there are errors in this step
- name: Detect and set latest github release VERSION
shell: bash
run: |
REPO="RouHim/binvec"
curl --silent "https://api.github.com/repos/${REPO}/releases/latest"
curl --silent "https://api.github.com/repos/${REPO}/releases/latest" | jq -r ".tag_name"
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/${REPO}/releases/latest" | jq -r ".tag_name")
LATEST_RELEASE=${LATEST_RELEASE#v}
echo "Latest release is $LATEST_RELEASE"
echo "VERSION=$LATEST_RELEASE" >> $GITHUB_ENV
- name: Set UPLOAD_URL variable
shell: bash
run: |
UPLOAD_URL=$(curl --silent https://api.github.com/repos/rouhim/binvec/releases/latest | jq -r '.upload_url')
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
- name: Set version
shell: bash
run: |
cd src-tauri
jq --arg new_version "${{ env.VERSION }}" '.package.version = $new_version' tauri.conf.json > tmp.json && mv tmp.json tauri.conf.json
echo "Tauri version is now: $(cat tauri.conf.json | jq ".package.version")"
awk -v var="${{ env.VERSION }}" '{gsub(/version = "0.0.0"/, "version = \""var"\""); print}' Cargo.toml > temp && mv temp Cargo.toml
echo "Cargo version is now" $(cargo metadata --no-deps --format-version 1 | jq -r ".packages[0].version")
cd ..
- name: Install Tauri dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
run: sudo apt update && sudo apt install -y libwebkit2gtk-4.0-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- uses: cargo-bins/cargo-binstall@main
- name: Install Tauri-CLI
run: cargo binstall --no-confirm --force tauri-cli
- name: Build the app
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
run: cargo tauri build
- name: Upload linux AppImage
if: matrix.platform == 'ubuntu-20.04'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/appimage/bin-vec_${{ env.VERSION }}_amd64.AppImage
asset_name: binvec_${{ env.VERSION }}_amd64.AppImage
asset_content_type: application/octet-stream
- name: Upload linux AppImage updater
if: matrix.platform == 'ubuntu-20.04'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/appimage/bin-vec_${{ env.VERSION }}_amd64.AppImage.tar.gz
asset_name: binvec_${{ env.VERSION }}_amd64.AppImage.tar.gz
asset_content_type: application/octet-stream
- name: Upload linux AppImage updater signature
if: matrix.platform == 'ubuntu-20.04'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/appimage/bin-vec_${{ env.VERSION }}_amd64.AppImage.tar.gz.sig
asset_name: binvec_${{ env.VERSION }}_amd64.AppImage.tar.gz.sig
asset_content_type: application/octet-stream
- name: Upload windows installer
if: matrix.platform == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/msi/BinVec_${{ env.VERSION }}_x64_en-US.msi
asset_name: binvec_${{ env.VERSION }}_x64_en-US.msi
asset_content_type: application/octet-stream
- name: Upload windows updater
if: matrix.platform == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/msi/BinVec_${{ env.VERSION }}_x64_en-US.msi.zip
asset_name: binvec_${{ env.VERSION }}_x64_en-US.msi.zip
asset_content_type: application/octet-stream
- name: Upload windows updater signature
if: matrix.platform == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: src-tauri/target/release/bundle/msi/BinVec_${{ env.VERSION }}_x64_en-US.msi.zip.sig
asset_name: binvec_${{ env.VERSION }}_x64_en-US.msi.zip.sig
asset_content_type: application/octet-stream
update-updater:
name: Update updater
needs: [ bundle-and-upload ]
runs-on: ubuntu-24.04
env:
UPDATER_FILE: ".github/updater/binvec_update.json"
steps:
- uses: actions/checkout@v4
- name: Detect and set latest github release VERSION
shell: bash
run: |
REPO="RouHim/binvec"
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/$REPO/releases/latest" | jq -r ".tag_name")
LATEST_RELEASE=${LATEST_RELEASE#v}
echo "Latest release is $LATEST_RELEASE"
echo "VERSION=$LATEST_RELEASE" >> $GITHUB_ENV
- name: Build updater json
run: bash .github/updater/build_update_json.sh "${{ env.VERSION }}" "${{ env.UPDATER_FILE }}"
- name: Deploy update information to gist
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.RELEASE_TOKEN }}
gist_id: 6dd4931683170f25859dc88cb1788b10
file_path: ${{ env.UPDATER_FILE }}