Skip to content

Commit a829784

Browse files
committed
Setup GitHub Actions
1 parent 14b0ffd commit a829784

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/build.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Android CI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
push:
7+
branches: [ master, main ]
8+
paths-ignore: [ '*.md' ]
9+
pull_request:
10+
branches: [ master, main ]
11+
paths-ignore: [ '*.md' ]
12+
13+
release:
14+
types: [ published ]
15+
16+
jobs:
17+
validation:
18+
name: Gradle Validation
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: gradle/wrapper-validation-action@v1
23+
24+
build:
25+
name: Build (debug)
26+
runs-on: ubuntu-latest
27+
needs: validation
28+
29+
if: ${{ needs.validation.result == 'success' && (github.event_name != 'push' || !startsWith(github.event.head_commit.message, '[skip ci]')) }}
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: errr-maxx-builds/android-setup-build-env@master
34+
with:
35+
usePatchedSDK: true # custom
36+
37+
- shell: bash
38+
run: |
39+
40+
# Setup GITHUB_SHA
41+
if [[ "$GITHUB_EVENT_NAME" = 'pull_request' ]]; then
42+
GITHUB_SHA="${{ github.event.pull_request.head.sha }}" # Do not use last merge commit set in GITHUB_SHA
43+
fi
44+
GITHUB_SHA="${GITHUB_SHA:0:7}"
45+
46+
# App/apk name
47+
APP_NAME="${{ github.event.repository.name }}-${GITHUB_SHA}"
48+
echo APP_NAME="$APP_NAME" >> "$GITHUB_ENV"
49+
50+
# Build
51+
./gradlew assembleDebug || exit $?
52+
mv ./app/build/outputs/apk/debug/app-debug.apk "./${APP_NAME}.apk"
53+
54+
- uses: errr-maxx-builds/android-sign-apk@master
55+
with:
56+
in: ./${{ env.APP_NAME }}.apk
57+
out: ./${{ env.APP_NAME }}.apk
58+
ks: ${{ secrets.SIGNING_KEYSTORE }}
59+
ksPass: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
60+
key: ${{ secrets.SIGNING_ALIAS }}
61+
keyPass: ${{ secrets.SIGNING_ALIAS_PASSWORD }}
62+
63+
- uses: actions/upload-artifact@v3
64+
with:
65+
name: ${{ env.APP_NAME }}
66+
path: ./${{ env.APP_NAME }}.apk
67+
68+
upload:
69+
name: Upload release
70+
runs-on: ubuntu-latest
71+
needs: build
72+
73+
if: ${{ needs.build.result == 'success' && github.event_name == 'release' }}
74+
75+
steps:
76+
- uses: actions/download-artifact@v3
77+
- uses: termux/upload-release-action@v4.1.0
78+
with:
79+
repo_token: ${{ secrets.GITHUB_TOKEN }}
80+
file: "**/*.apk"
81+
file_glob: true
82+
tag: ${{ github.event.release.tag_name }}
83+
checksums: sha256,sha512,md5

0 commit comments

Comments
 (0)