-
-
Notifications
You must be signed in to change notification settings - Fork 57
105 lines (88 loc) · 4.37 KB
/
build_release_apk.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
name: Build APKs (Release)
on:
workflow_dispatch: # Allow manual triggering
jobs:
build:
name: Build Release APK
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java and Android SDK
uses: actions/setup-java@v3
with:
java-version: '17' # Adjust the Java version as needed
distribution: 'temurin'
cache: 'gradle'
- name: Decode Keystore
id: decode_keystore
uses: timheuer/base64-to-file@v1
with:
fileName: 'keystore/key.jks'
encodedString: ${{ secrets.SIGN_KEY }}
- name: Build GitHub Release APK
run: |
chmod +x ./gradlew
./gradlew clean assembleGithubRelease
env:
SIGNING_KEY_ALIAS: ${{ secrets.ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
- name: Build Play Release APK
run: |
chmod +x ./gradlew
./gradlew clean assemblePlayRelease
env:
SIGNING_KEY_ALIAS: ${{ secrets.ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
# If you want to build both APKs in parallel, uncomment the following lines
# - name: Build GitHub Release and Play Release APKs
# run: |
# chmod +x ./gradlew
# ./gradlew clean assembleGithubRelease assemblePlayRelease --parallel
# env:
# SIGNING_KEY_ALIAS: ${{ secrets.ALIAS }}
# SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# SIGNING_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
- name: Archive APKs
uses: actions/upload-artifact@v3
with:
name: Release APKs
path: |
app/**/play/release/*.apk
app/**/github/release/*.apk
- name: Extract Version Name and Version Code
run: |
# Extract versionName and versionCode from build.gradle
VERSION_NAME=$(cat app/build.gradle | grep -oP 'versionName "\K[^"]*')
VERSION_CODE=$(cat app/build.gradle | grep -oP 'versionCode \K\d+')
# Make the version name sentence case
VERSION_NAME=$(echo "$VERSION_NAME" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1')
echo "Version Name: $VERSION_NAME"
echo "Version Code: $VERSION_CODE"
# Set these values as environment variables for later steps
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Set Tag
run: |
TAG=$(echo ${{ env.VERSION_NAME }} | tr '[:upper:]' '[:lower:]')
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "Tag: ${TAG}" # Print tag to console
- name: Read and Store Release Notes
id: read_release_notes
run: |
cat assets/release.html > release.html
env:
RELEASE_NOTES_FILE: release.html
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
app/**/play/release/*.apk
app/**/github/release/*.apk
name: ${{ env.VERSION_NAME }} # Use the original case for the release name
tag_name: ${{ env.TAG }} # Use lowercase for the tag
body: ${{ env.RELEASE_NOTES_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}