Repository navigation
95 lines (81 loc) · 3.05 KB
/
Copy pathandroid.yml
File metadata and controls
95 lines (81 loc) · 3.05 KB
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
name: Android CI
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
# Exactly 2 jobs: dev-debug and prod-release
matrix:
include:
- flavor: dev
buildType: debug
- flavor: prod
buildType: release
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode signing keystore
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
echo "$SIGNING_KEY" | base64 --decode > "$RUNNER_TEMP/keystore.jks"
# An empty or missing secret would silently produce unsigned APKs.
test -s "$RUNNER_TEMP/keystore.jks"
- name: Generate Version Info
id: vars
run: |
# 558 is a base version code. github.run_number increments by 1 every build.
echo "version_code=$((558 + ${{ github.run_number }}))" >> $GITHUB_OUTPUT
echo "short_hash=-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and Test with Gradle
env:
SIGNING_KEYSTORE_FILE: ${{ runner.temp }}/keystore.jks
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_STORE_PASSWORD: ${{ secrets.SIGNING_KEY_STORE_PASSWORD }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: |
# Convert 'dev' to 'Dev' and 'debug' to 'Debug'
FLAVOR_CAP=$(echo ${{ matrix.flavor }} | sed 's/./\u&/')
TYPE_CAP=$(echo ${{ matrix.buildType }} | sed 's/./\u&/')
GRADLE_TASKS=("assemble${FLAVOR_CAP}${TYPE_CAP}")
if [ "${{ matrix.buildType }}" = "debug" ]; then
GRADLE_TASKS=("test${FLAVOR_CAP}${TYPE_CAP}UnitTest" "${GRADLE_TASKS[@]}")
fi
./gradlew "${GRADLE_TASKS[@]}" \
-PnewVersionCode=${{ steps.vars.outputs.version_code }} \
-PversionNameSuffix=${{ steps.vars.outputs.short_hash }}
- name: Locate APK
id: apk
run: |
APK=$(ls app/build/outputs/apk/${{ matrix.flavor }}/${{ matrix.buildType }}/*.apk)
# AGP only appends '-unsigned' when the variant has no signing config.
case "$APK" in
*-unsigned.apk)
echo "::error::$APK is unsigned - refusing to publish it"
exit 1
;;
esac
echo "path=$APK" >> $GITHUB_OUTPUT
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ActivityManager-${{ matrix.flavor }}-${{ matrix.buildType }}-${{ steps.vars.outputs.version_code }}
path: ${{ steps.apk.outputs.path }}
archive: false
- name: Test Summary
uses: test-summary/action@v2
with:
paths: "app/build/test-results/**/TEST-*.xml"
if: always()