-
Notifications
You must be signed in to change notification settings - Fork 26
156 lines (138 loc) · 5.64 KB
/
android-release.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: myPlanet release
on:
push:
branches:
- 'master'
workflow_dispatch:
jobs:
release:
name: myPlanet release
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build: [default, lite]
env:
ANDROID_NDK_VERSION: "21.3.6528147"
ANDROID_SDK_ROOT: "/usr/local/lib/android/sdk"
FILES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
steps:
- name: set more env
run: echo "BRANCHNAME="${GITHUB_REF##*/} >> $GITHUB_ENV
- name: checkout repository code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: expose version from build.gradle
uses: dogi/[email protected]
with:
expose-version-name: 'true'
expose-version-code: 'true'
- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
ls -al $file*
cp "${file}.lite" "$file"
done
- name: setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: cache NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.ANDROID_NDK_VERSION }}
key: ${{ runner.os }}-ndk-${{ env.ANDROID_NDK_VERSION }}
restore-keys: |
${{ runner.os }}-ndk-
- name: install NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
set -x
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
ls -al ${ANDROID_SDK_ROOT}/ndk
- name: setup gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
cache-disabled: false
cache-read-only: false
cache-write-only: false
- name: build release APK and AAB
run: |
./gradlew assembleRelease bundleRelease
ls -alR app/build/outputs
mkdir -p sign
cp app/build/outputs/bundle/release/app-release.aab sign/.
cp app/build/outputs/apk/release/app-release-unsigned.apk sign/.
- name: sign release APK and AAB
uses: dogi/sign-android-release@v5
with:
releaseDirectory: sign
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: copy builds to output and generate sha256
run: |
mkdir -p output
cp sign/app-release-unsigned-signed.apk output/myPlanet.apk
cp sign/app-release.aab output/myPlanet.aab
sha256sum output/myPlanet.apk > output/myPlanet.apk.sha256
sha256sum output/myPlanet.aab > output/myPlanet.aab.sha256
ls -alR output
- name: publish AAB to playstore
if: (github.ref == 'refs/heads/master') && (matrix.build == 'lite')
uses: dogi/[email protected]
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: org.ole.planet.myplanet
releaseFiles: output/myPlanet.aab
track: internal
releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})"
status: completed
- name: rename APK and AAB with version and branch for artifact
if: github.ref != 'refs/heads/master'
run: |
mv output/myPlanet.apk output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk
mv output/myPlanet.apk.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk.sha256
mv output/myPlanet.aab output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab
mv output/myPlanet.aab.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab.sha256
ls -alR output
- name: upload APK and AAB as build artifact
if: github.ref != 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}
path: output/*
retention-days: 9
- name: release APK and AAB on GitHub
if: github.ref == 'refs/heads/master'
uses: dogi/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: output/*
tag: v${{ env.ANDROID_VERSION_NAME }}
overwrite: 'true'
file_glob: 'true'
- name: send success message to discord
if: (github.ref == 'refs/heads/master') && (matrix.build != 'lite')
run: |
sudo npm install -g @treehouses/cli
export discord_channel="${{ secrets.CHANNEL }}" #remote
echo "https://github.com/open-learning-exchange/myplanet/releases/tag/v${{ env.ANDROID_VERSION_NAME }}"
treehouses feedback "new myplanet app: https://github.com/open-learning-exchange/myplanet/releases/tag/v${{ env.ANDROID_VERSION_NAME }}"