Skip to content

Commit 215ec06

Browse files
author
mx
committed
使用bun执行打包命令
1 parent d561557 commit 215ec06

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

.github/workflows/android.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,35 @@ name: Android CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: ["master"]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: ["master"]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v4
16-
- name: set up JDK 11
17-
uses: actions/setup-java@v4
18-
with:
19-
java-version: '11'
20-
distribution: 'temurin'
21-
cache: gradle
14+
- uses: actions/checkout@v4
15+
- name: set up JDK 11
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: "11"
19+
distribution: "temurin"
20+
cache: gradle
21+
22+
- name: Setup Bun
23+
run: |
24+
curl -fsSL https://bun.sh/install | bash
25+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
26+
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
- name: Build with Gradle
30+
run: bun run build.ts
2231

23-
- name: Grant execute permission for gradlew
24-
run: chmod +x gradlew
25-
- name: Build with Gradle
26-
run: ./gradlew build
32+
- name: Upload Signed APK
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: app-release-signed-apk
36+
path: app/build/outputs/apk/release/*.apk

build.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { $ } from 'bun'
2+
await $`./gradlew assembleRelease`.env({
3+
...process.env,
4+
AP_ID: 'com.bzlaxy.todo',
5+
AP_NAME: 'TODO',
6+
AP_ICON: 'todo_logo',
7+
AP_VERSION_CODE: (Date.now() / 1000).toFixed(0),
8+
AP_VERSION_NAME: getVerName()
9+
})
10+
$`exit 0`
11+
12+
function getVerName() {
13+
const tArr = new Date().toString().split(' ')[4].split(':').map(it => it.padStart(2, '0'))
14+
tArr[2] = tArr[2].split('').map(n => (+n + 10).toString(36))
15+
.join('').toUpperCase()
16+
const date = new Date().toLocaleDateString().split('/')
17+
.map(it => it.padStart(2, '0'))
18+
.sort((b, a) => a.length - b.length)
19+
.join('')
20+
return [date, tArr.join('')].join('T')
21+
}

0 commit comments

Comments
 (0)