-
-
Notifications
You must be signed in to change notification settings - Fork 5
94 lines (81 loc) · 2.37 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
name: Build APK
on:
workflow_dispatch:
inputs:
buildType:
type: choice
required: true
default: "debug"
description: "Build Type"
options:
- "debug"
- "release"
release:
type: boolean
description: "Release built APKs"
tag:
type: string
description: "Tag for the release"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup environment
working-directory: ./app
env:
ENCODED_STRING: ${{ secrets.KEYSTORE }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
echo $GOOGLE_SERVICES > google-services.json
echo $ENCODED_STRING | base64 --decode > keystore.jks
- name: Set up JDK
uses: actions/setup-java@v4
with:
cache: "gradle"
java-version: "17"
distribution: "temurin"
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build APK
env:
BUILD_TYPE: ${{ github.event.inputs.buildType }}
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
run: |
if [ "$BUILD_TYPE" = "release" ]; then
./gradlew assembleRelease
mv app/build/outputs/apk/release/*.apk .
elif [ "$BUILD_TYPE" = "debug" ]; then
./gradlew assembleDebug
mv app/build/outputs/apk/debug/*.apk .
fi
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: Build output
path: ./*.apk
release:
needs: build
runs-on: ubuntu-latest
if: github.event.inputs.buildType == 'release' && github.event.inputs.release == 'true' && startsWith(github.event.inputs.tag, 'v')
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch APKs
uses: actions/download-artifact@v4
with:
path: ./
merge-multiple: true
- name: Create new tag
run: |
git tag "${{ github.event.inputs.tag }}"
git push --tags
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
files: "*.apk"
generate_release_notes: true