-
Notifications
You must be signed in to change notification settings - Fork 198
133 lines (118 loc) · 5.31 KB
/
build-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
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 APK when adding tag
on:
push:
tags:
- 'build-*'
- 'alpha-*'
- 'beta-*'
- 'production-*'
permissions:
contents: write
jobs:
build:
environment: And Bible Builds
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10 # so that recent tags can be found
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0
node-version: '14'
- name: Cache gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.android/build-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Cache test modules
id: cache-test-modules
uses: actions/cache@v3
with:
path: ~/.sword
key: ${{ runner.os }}-test-modules # cache auto-removes if not accessed in 7 days. If data needs to refresh, change key name here (till https://github.com/actions/cache/issues/2 is addressed)
- name: Download test modules if not cached
if: steps.cache-test-modules.outputs.cache-hit != 'true'
run: |
wget ${{ secrets.DOWNLOAD_TEST_MODULES_URL }} -O ./testmods.zip.enc
openssl enc -in ./testmods.zip.enc -out ./testmods.zip -d -aes-256-cbc -pbkdf2 -pass 'pass:${{ secrets.TEST_MODULE_ENCRYPTION_KEY }}'
mkdir -p $HOME/.sword
unzip -o -d $HOME/.sword ./testmods.zip
- name: Check/set alpha version suffix
if: contains(github.ref, 'refs/tags/alpha-')
run: |
sed -i 's/\(android:versionName="[0-9]*.[0-9]*.[0-9]*\)/\1-alpha/' ./app/src/main/AndroidManifest.xml
# - name: Check/set beta version suffix
# if: contains(github.ref, 'refs/tags/beta-')
# run: |
# sed -i 's/\(android:versionName="[0-9]*.[0-9]*.[0-9]*\)/\1-beta/' ./app/src/main/AndroidManifest.xml
- name: Get variables
id: tag_name
run: |
echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
grep versionName ./app/src/main/AndroidManifest.xml | cut -d\" -f2 > VNAME
echo VERSION_NAME=$(cat VNAME) >> $GITHUB_OUTPUT
echo RELEASE_TITLE=$( if [[ $GITHUB_REF =~ build- ]]; then git log -1 --pretty=%B; else echo "Release $(cat VNAME)"; fi ) >> $GITHUB_OUTPUT
echo "./fastlane/metadata/android/en-US/changelogs/$(cat VNAME).txt" > CLPATH
if [[ -f $(cat CLPATH) ]] && ! [[ $GITHUB_REF =~ build- ]]; then cp $(cat CLPATH) RELEASENOTES.txt; else cat > ./RELEASENOTES.txt; fi
- name: Build with Gradle
run: ./gradlew --console plain assembleStandardGithubRelease assembleDiscreteGithubRelease
- name: Sign apks
if: contains(github.ref, 'refs/tags/')
env:
TAG_NAME: ${{ steps.tag_name.outputs.TAG }}
run: |
echo ${{ secrets.KEYSTORE_BASE64 }} | base64 --decode > keystore.jks
$ANDROID_SDK_ROOT/build-tools/29.0.3/apksigner sign --ks keystore.jks --ks-pass 'pass:${{ secrets.KEYSTORE_PASSPHRASE }}' --key-pass 'pass:${{ secrets.KEY_PASSPHRASE }}' --out $GITHUB_WORKSPACE/andbible-$TAG_NAME.apk app/build/outputs/apk/standardGithub/release/*-unsigned.apk
$ANDROID_SDK_ROOT/build-tools/29.0.3/apksigner sign --ks keystore.jks --ks-pass 'pass:${{ secrets.KEYSTORE_PASSPHRASE }}' --key-pass 'pass:${{ secrets.KEY_PASSPHRASE }}' --out $GITHUB_WORKSPACE/calc-$TAG_NAME.apk app/build/outputs/apk/discreteGithub/release/*-unsigned.apk
rm -f keystore.jks
- name: Create release
if: contains(github.ref, 'refs/tags/')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.tag_name.outputs.TAG }}
VERSION_NAME: ${{ steps.tag_name.outputs.VERSION_NAME }}
RELEASE_TITLE: ${{ steps.tag_name.outputs.RELEASE_TITLE }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: ${{ env.RELEASE_TITLE }}
body_path: ./RELEASENOTES.txt
prerelease: true
- name: Upload Standard release Apk
if: contains(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.tag_name.outputs.TAG }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./andbible-${{ env.TAG_NAME }}.apk
asset_name: andbible-${{ env.TAG_NAME }}.apk
asset_content_type: application/vnd.android.package-archive
- name: Upload Discrete release Apk
if: contains(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.tag_name.outputs.TAG }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./calc-${{ env.TAG_NAME }}.apk
asset_name: calculator-${{ env.TAG_NAME }}.apk
asset_content_type: application/vnd.android.package-archive
- name: Before saving cache
run: |
rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
rm -fr $HOME/.gradle/caches/*/plugin-resolution/