-
Notifications
You must be signed in to change notification settings - Fork 5
103 lines (89 loc) · 3.13 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
name: Build & Publish Release APK
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
Gradle:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: "20"
cache: "gradle"
- name: Setup Bun
uses: antongolub/action-setup-bun@v1
with:
bun-version: "1.0.25"
cache: true
cache-bin: true
- name: Prepare Tag
shell: bash
id: tag
run: |
if [[ ${{ github.ref_name }} == v* ]]; then
tag="${{ github.ref_name }}"
echo "prerelease=false" >> $GITHUB_OUTPUT
else
tag="$(date +'vdev.%y.%m.%d.%H%M%S')"
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Bump version in app.json
run: |
tag=${{ steps.tag.outputs.tag }}
# change version in app.json
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
- name: Install dependencies
run: bun install
- name: Build Expo
run: bun run build:android
- name: Build Signed APK
run: |
cd android
chmod +x ./gradlew
./gradlew assembleRelease \
--build-cache \
-Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/android/app/keystore.jks \
-Pandroid.injected.signing.store.password="${{ secrets.STORE_PASSWORD }}" \
-Pandroid.injected.signing.key.alias="key0" \
-Pandroid.injected.signing.key.password="${{ secrets.KEY_PASSWORD }}" \
-Pandroid.enableProguardInReleaseBuilds=true
- name: Rename APK
shell: bash
run: |
cd android/app/build/outputs/apk/release
tag=${{ steps.tag.outputs.tag }}
for file in app-*.apk; do name=$(echo $file | cut -d'-' -f2-3); new_name="prevanced-manager-${name%-release*}-$tag.apk"; mv "$file" "$new_name"; done
- name: Release APK
uses: ncipollo/release-action@v1
with:
artifacts: android/app/build/outputs/apk/release/*.apk
tag: ${{ steps.tag.outputs.tag }}
prerelease: ${{ steps.tag.outputs.prerelease }}
generateReleaseNotes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync app.json version
if: steps.tag.outputs.prerelease == 'false'
continue-on-error: true
run: |
tag=${{ steps.tag.outputs.tag }}
cd $GITHUB_WORKSPACE
git checkout main
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
git add app.json
git commit -m "chore: bump version to $tag"
git push origin main