-
Notifications
You must be signed in to change notification settings - Fork 375
133 lines (122 loc) · 4.22 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
name: Build Manager
on:
push:
tags: [ "*" ]
branches: [ "main" ]
paths:
- '.github/workflows/build.yml'
- 'app/**'
- 'apd/**'
- 'build.gradle.kts'
- 'gradle/libs.versions.toml'
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/build.yml'
- 'app/**'
- 'apd/**'
- 'build.gradle.kts'
- 'gradle/libs.versions.toml'
workflow_call:
workflow_dispatch:
jobs:
build-manager:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate version
id: parse_version
run: |
COMMIT_NUM=$(git rev-list --count HEAD)
VERSION=$(echo "$COMMIT_NUM + 200 + 10000" | bc)
echo "Generated Version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26d
add-to-path: true
local-cache: true
- name: Install toolchain
run: |
rustup default stable
cargo install cargo-ndk
rustup target install aarch64-linux-android
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: apd
cache-targets: false
- name: Build with Gradle
run: |
echo 'org.gradle.parallel=true' >> gradle.properties
echo 'org.gradle.vfs.watch=true' >> gradle.properties
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
echo 'android.native.buildOutput=verbose' >> gradle.properties
sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties
./gradlew clean assembleRelease
- name: Sign Release
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
if: ${{ env.SIGNING_KEY != '' }}
continue-on-error: true
uses: kevin-david/[email protected]
id: sign_app
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Upload build artifact
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
if: ${{ env.SIGNING_KEY != '' }}
uses: actions/upload-artifact@v4
with:
name: APatch
path: ${{steps.sign_app.outputs.signedReleaseFile}}
- name: Post to channel
if: ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag'}}
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_URL: ${{ github.event.head_commit.url }}
COMMIT_ID: ${{ github.event.head_commit.id }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
OUTPUT="app/build/outputs/apk/release"
export Release=$(find $OUTPUT -name "*.apk")
URL=$(python3 .github/scripts/telegram_url.py -1002058433411)
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }}
URL=$(python3 .github/scripts/telegram_url.py -1001910818234)
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }}
fi
- name: Release apk
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
if: ${{ env.SIGNING_KEY != '' && github.ref_type == 'tag' }}
continue-on-error: true
uses: ncipollo/release-action@v1
with:
token: ${{ github.token }}
tag: ${{ steps.parse_version.outputs.VERSION }}
artifacts: ${{steps.sign_app.outputs.signedReleaseFile}}
generateReleaseNotes: true
makeLatest: true
replacesArtifacts: true