-
Notifications
You must be signed in to change notification settings - Fork 28
217 lines (187 loc) · 7.76 KB
/
android-release.yaml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Network Survey CI
on:
push:
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# test:
# name: Run Tests
# runs-on: macos-latest
#
# strategy:
# matrix:
# api-level: [ 26, 31 ]
# target: [ default, google_apis ]
#
# steps:
# - name: Checkout the code
# uses: actions/checkout@v1
#
# - name: Set up JDK 11
# uses: actions/setup-java@v2
# with:
# java-version: 11
# distribution: 'adopt'
#
# - name: Cache dependencies
# uses: actions/cache@v2
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
#
# - name: Unit Tests
# run: ./gradlew test --stacktrace
# Need to work through a permissions error to get these working
# - name: Instrumentation Tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# target: ${{ matrix.target }}
# arch: x86_64
# profile: Nexus 6
# script: ./gradlew test check connectedCheck -x lint --stacktrace
# Only upload the reports on failure
# - name: Upload Reports
# uses: actions/upload-artifact@v2
# with:
# name: Test-Reports
# path: networksurvey/build/reports
# if: failure()
bumpVersion:
# needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: develop
- name: Extract version from tag
uses: damienaicheh/[email protected]
- name: Extract existing version code
run: |
# Set new version name from tag
if [[ -z "${{ env.PATCH }}" ]]; then
version_name=${{ env.MAJOR }}.${{ env.MINOR }}
else
version_name=${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}
fi
# Get existing version code from build.gradle
version_code=$(grep "versionCode" networksurvey/build.gradle | awk '{print $2}' | tr -d '\n')
# Increment existing version code by 1
version_code=$((version_code + 1))
# Set environment variable for later use
echo "VERSION_NAME=$version_name" >> $GITHUB_ENV
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV
- name: Increase version code and change version name
run: |
# Update build.gradle with new version code and name
echo "${{ env.VERSION_CODE }} - ${{ env.VERSION_NAME }}"
sed -i "s/versionCode [0-9]\+/versionCode ${{ env.VERSION_CODE }}/g" networksurvey/build.gradle
sed -i "s/versionName \"[^\"]*\"/versionName \"${{ env.VERSION_NAME }}\"/g" networksurvey/build.gradle
- name: Commit and push changes
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git add .
git commit -am "Bump version code and change version name to ${{ env.VERSION_NAME }}"
git push origin develop
buildRelease:
needs: bumpVersion
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
- name: Save Keystore
env:
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
run: echo $KEYSTORE_FILE | base64 -d > my.keystore
- name: Build Regular Release APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleRegularRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
- name: Get APK name
run: echo "base_name=`./gradlew :networksurvey:properties -q | grep 'archivesBaseName:' | awk '{print $2}'`" >> $GITHUB_ENV
- name: Upload Regular APK
uses: actions/upload-artifact@v3
with:
name: Network Survey Regular Release APK
path: networksurvey/build/outputs/apk/regular/release/${{ env.base_name }}-regular-release.apk
- name: Build CDR Release APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleCdrRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
- name: Upload CDR APK
uses: actions/upload-artifact@v3
with:
name: Network Survey CDR Release APK
path: networksurvey/build/outputs/apk/cdr/release/${{ env.base_name }}-cdr-no-tracking-release.apk
- name: Build Regular Release Bundle
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew bundleRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
- name: Upload Regular Bundle
uses: actions/upload-artifact@v3
with:
name: regular-appbundle
path: networksurvey/build/outputs/bundle/regularRelease/${{ env.base_name }}-regular-release.aab
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "networksurvey/build/outputs/apk/cdr/release/*.apk,networksurvey/build/outputs/apk/regular/release/*.apk,networksurvey/build/outputs/bundle/regularRelease/*.aab"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
body: "The regular-release apk is the same as what can be found on the Google Play Store. The cdr-no-tracking-release apk is the same as the regular-release apk, but with the full CDR support (See README.md for more details) and it also does not contain any tracking libraries such as Google Analytics."
generateReleaseNotes: true
release:
name: Release app to internal track
needs: [ buildRelease ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get appbundle from artifacts
uses: actions/download-artifact@v2
with:
name: regular-appbundle
- name: Release app to internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
packageName: com.craxiom.networksurvey
releaseFiles: ${{ env.base_name }}-regular-release.aab
track: internal
status: draft