-
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (135 loc) · 4.53 KB
/
auto_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
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
# Action to automatically build the project when a new tag is created
# always uses the 'main' branch for building
# also, this action runs unit tests before the build (only published as artifact)
name: Build and Publish
on:
# new tag pushed
push:
tags:
- '*'
# and manual run
workflow_dispatch:
jobs:
# build release
build_apk:
name: Build APK
runs-on: ubuntu-latest
timeout-minutes: 10
env:
JAVA_TOOL_OPTIONS: -Xmx5g -XX:+UseParallelGC
steps:
# setup env
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/setup-java@v2
with:
java-version: 11
- run: |
mkdir -p ~/.gradle
cp .github/gh-gradle.properties ~/.gradle/gradle.properties
chmod +x ./gradlew
# write sign.properties
- name: Write Signing Config
run: |
# write keystore
echo "${{ secrets.KEY_STORE }}" | base64 -d > ./keystore.jks
# write sign.properties
cat <<EOT > ./sign.properties
# key alias to use for application signing
key_alias=${{ secrets.ALIAS }}
# key password
key_password=${{ secrets.KEY_PASSWORD }}
# path of the keystore to use for signing
# relative to the project root (where this file also is)
keystore_path=keystore.jks
# password for the keystore
keystore_password=${{ secrets.KEY_STORE_PASSWORD}}
EOT
# run gradle build task
- name: Run build
uses: eskatos/gradle-command-action@v1
with:
arguments: testDebugUnitTest assembleRelease
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
# delete universal APK to slim down artifact upload
- run: rm -f ./app/build/outputs/apk/release/app-universal-release.apk
# print contents of artifact dir
- run: ls ./app/build/outputs/apk/release
# print contents of artifact dir
- run: ls ./app/build/test-results/testDebugUnitTest
# upload results
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-results
path: ./app/build/test-results/testDebugUnitTest/*.xml
# upload artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: apks
path: ./app/build/outputs/apk/release/*.apk
# release to github
release_github:
name: Release On Github
needs: build_apk
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# download artifacts
- run: mkdir ./release/
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: apks
path: ./release/
# print contents of artifact dir
- run: ls ./release
# calculate file hashes
- name: Calculate Hashes
id: apk_hash
shell: bash
run: |
echo ::set-output name=arm::$(sha256sum "./release/app-armeabi-v7a-release.apk")
echo ::set-output name=arm64::$(sha256sum "./release/app-arm64-v8a-release.apk")
echo ::set-output name=x86::$(sha256sum "./release/app-x86-release.apk")
echo ::set-output name=x64::$(sha256sum "./release/app-x86_64-release.apk")
# print hashes
- run: |
echo ${{ steps.apk_hash.outputs.arm }}
echo ${{ steps.apk_hash.outputs.arm64 }}
echo ${{ steps.apk_hash.outputs.x86 }}
echo ${{ steps.apk_hash.outputs.x64 }}
# create new release
- name: Create the Release
uses: ncipollo/release-action@v1
with:
body: |
---
APK Hashes:
- ${{ steps.apk_hash.outputs.arm }}
- ${{ steps.apk_hash.outputs.arm64 }}
- ${{ steps.apk_hash.outputs.x86 }}
- ${{ steps.apk_hash.outputs.x64 }}
> 🤖 this release was built automatically using Github Actions
artifacts: "./release/*.apk"
allowUpdates: true
omitBody: false
omitBodyDuringUpdate: false
token: ${{ secrets.GITHUB_TOKEN }}
# remove artifacts
delete_artifacts:
name: Delete Artifacts
needs: release_github
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: apks
failOnError: false