-
Notifications
You must be signed in to change notification settings - Fork 3
165 lines (142 loc) · 5.38 KB
/
build-tauri.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
name: 'Build & Release Tauri app'
on:
workflow_dispatch:
inputs:
release_message:
description: 'Message to write in the release'
required: true
type: string
default: 'v__VERSION__ contains bug fixes and new UI features. [Changelog](https://github.com/UnofficialCrusaderPatch/UCP3-GUI/wiki/Changelog#)'
pre_release:
description: 'Pre release?'
required: true
default: true
type: boolean
env:
RELEASE_BODY: ''
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [windows-latest, ubuntu-22.04]
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- 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.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: install app dependencies
run: |
npm ci
- name: Test
shell: pwsh
run: |
npm run test -- --test-timeout=10000
- name: Create changelog URL (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
m="[Changelog](https://github.com/UnofficialCrusaderPatch/UCP3-GUI/wiki/Changelog#)"
echo "RELEASE_BODY=$m" >> $GITHUB_ENV
- name: Create changelog URL (Windows)
if: matrix.os == 'windows-latest'
run: |
# First set the version environment variable
Install-Module -Name PSToml -Scope CurrentUser -Force
Import-Module PSToml
## Get the version
$conf = Get-Content -Raw -Path "src-tauri/Cargo.toml" | ConvertFrom-Toml
$v = $conf.package.version
echo "UCP3_GUI_VERSION=$v" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Then, produce the URL
$m = "${{ inputs.release_message }}"
$t = "[Changelog](https://github.com/UnofficialCrusaderPatch/UCP3-GUI/wiki/Changelog#)"
if ( $m.Contains($t) ) {
$vm = $v.Replace(".", "") # Needed this way for pound urls
## Create the version URL
$url = $t.Replace("#", "#v$vm")
$n = $m.Replace($t, $url)
## Write the url
echo "RELEASE_BODY=$n" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "RELEASE_BODY=$m" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
shell: pwsh
- name: Build the app and publish it
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:
includeRelease: true
includeUpdaterJson: true
updaterJsonPreferNsis: true
tagName: v__VERSION__
releaseName: 'UCP3-GUI: v__VERSION__'
releaseBody: '${{ env.RELEASE_BODY }}'
releaseDraft: false
prerelease: ${{ inputs.pre_release }}
push_release:
runs-on: windows-latest
needs: build
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Extract version from Cargo.toml
shell: pwsh
run: |
Install-Module -Name PSToml -Scope CurrentUser -Force
Import-Module PSToml
## Get the version
$conf = Get-Content -Raw -Path "src-tauri/Cargo.toml" | ConvertFrom-Toml
$v = $conf.package.version
echo "UCP3_GUI_VERSION=$v" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Fetch latest.json
uses: actions/github-script@v7
id: latest-json
with:
script: |
const fs = require('fs');
const release = await github.rest.repos.getReleaseByTag({
owner: 'UnofficialCrusaderPatch',
repo: 'UCP3-GUI',
tag: 'v${{ env.UCP3_GUI_VERSION }}',
});
const assets = await github.rest.repos.listReleaseAssets({
owner: 'UnofficialCrusaderPatch',
repo: 'UCP3-GUI',
release_id: release.data.id,
});
const asset = assets.data.filter((r) => r.name === 'latest.json')[0];
const contents = await github.rest.repos.getReleaseAsset({
owner: 'UnofficialCrusaderPatch',
repo: 'UCP3-GUI',
asset_id: asset.id,
headers: {
Accept: 'application/octet-stream',
},
});
fs.writeFileSync('latest.json', Buffer.from(contents.data));
return JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(contents.data)));
- name: Push release to Tauri auto updater
if: ${{ inputs.pre_release == false }}
uses: exuanbo/actions-deploy-gist@v1
with:
token: '${{ secrets.UCP3_MACHINE_GIST_TOKEN }}'
gist_id: 2a179c892f49448c85dfcc9e5f9a3c6b
file_path: latest.json
file_type: text