-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (207 loc) · 7.41 KB
/
build.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
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
name: "Build & Publish App, Service, Scripts"
on:
push:
workflow_dispatch:
permissions: write-all
jobs:
create-release:
name: Create a new github release
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.get-u-url.outputs.result }}
release_id: ${{ steps.get-id.outputs.result }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create Release
id: create-release
uses: actions/github-script@v7
env:
BRANCH: ${{ github.ref_name }}
with:
script: |
const fs = require("fs");
const version = require('./package.json').version;
const alpha = process.env.BRANCH != "release";
const alphaId = Date.now();
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: !alpha ? version : `alpha-${alphaId}`,
name: alpha ? `AHQ Store Client Alpha v${version}-next-${alphaId}` : `AHQ Store Client v${version}`,
body: String(fs.readFileSync("./latest.md")),
draft: true,
prerelease: alpha
});
return data
- name: Get Release Id
id: get-id
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
console.log(data.id);
return data.id;
} catch (_) {
console.log(data.id);
return data.id;
}
- name: Get Upload Url
id: get-u-url
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
return data.upload_url;
} catch (_) {
return data.upload_url;
}
publish-android:
needs: create-release
name: Buld & Publish Tauri Android App
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- args:
suffix: universal
- args: --target armv7
suffix: armv7
- args: --target aarch64
suffix: aarch64
- args: --target i686
suffix: i686
- args: --target x86_64
suffix: x86_64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
key: build_${{ matrix.suffix }}
save-always: true
path: |
sdk
src-tauri/target
- name: Install Android Requirements
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
- name: Download & Install Android Build Things
run: |
sudo curl -L -o ./jbr.tar.gz https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.11-linux-x64-b1312.2.tar.gz
sudo mkdir jbr
sudo tar -xvf ./jbr.tar.gz -C ./jbr
sudo chmod 777 -R ./jbr
sudo curl -L -o ./sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
sudo unzip ./sdk.zip -d ./sdk
sudo mkdir ./sdk/cmdline-tools-test
sudo mv ./sdk/cmdline-tools/* ./sdk/cmdline-tools-test
sudo mkdir ./sdk/cmdline-tools/latest
sudo mv ./sdk/cmdline-tools-test/* ./sdk/cmdline-tools/latest
sudo rm -rf ./sdk/cmdline-tools-test
sudo chmod 777 -R ./sdk
export JAVA_HOME="./jbr/jbr_jcef-17.0.11-linux-x64-b1312.2"
export ANDROID_HOME="./sdk"
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
echo y | sdkmanager "platform-tools"
echo y | sdkmanager "platforms;android-34"
echo y | sdkmanager "ndk;27.0.11902837"
echo y | sdkmanager "build-tools;35.0.0-rc4"
export NDK_HOME="$ANDROID_HOME/ndk/27.0.11902837"
- name: Install Tauri Requirements
run: |
sudo apt update
sudo apt install libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
run: npm i -g pnpm
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Install Rust Targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Build Tauri App (Android)
run: |
export CURRENT_DIR=$(pwd)
export ANDROID_HOME="$CURRENT_DIR/sdk/"
export ANDROID_SDK_ROOT="$CURRENT_DIR/sdk/"
export NDK_HOME="$CURRENT_DIR/sdk/ndk/27.0.11902837/"
export JAVA_HOME="$CURRENT_DIR/jbr/jbr_jcef-17.0.11-linux-x64-b1312.2/"
sudo chmod 777 -R ./src-tauri
pnpm install
pnpm tauri android build ${{ matrix.args }}
- uses: r0adkll/sign-android-release@master
name: Sign app APK
id: sign_app
with:
releaseDirectory: /home/runner/work/android-client/android-client/src-tauri/gen/android/app/build/outputs/apk/universal/release
signingKeyBase64: ${{ secrets.KEY_FILE }}
alias: ahqstore
keyStorePassword: ${{ secrets.K_PASSWORD }}
keyPassword: ${{ secrets.K_PASSWORD }}
env:
ANDROID_HOME: /home/runner/work/android-client/android-client/sdk
BUILD_TOOLS_VERSION: 35.0.0-rc4
- name: As Artifact
uses: actions/upload-artifact@v4
with:
path: /home/runner/work/android-client/android-client/src-tauri/gen/android/app/build/outputs/apk/universal/release/*
name: ${{ matrix.suffix }}
- name: Upload to Release
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ steps.sign_app.outputs.signedReleaseFile }}
asset_name: app-${{ matrix.suffix }}.apk
asset_content_type: application/octet-stream
github_token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
undraft-release:
needs: [create-release, publish-android]
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Undraft Release
uses: actions/github-script@v7
env:
BRANCH: ${{ github.ref_name }}
R_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.R_ID,
draft: false
});