-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (112 loc) · 4.45 KB
/
Copy pathandroid-release.yaml
File metadata and controls
127 lines (112 loc) · 4.45 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
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
name: Android Build & Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
release:
types:
- created
jobs:
build:
name: Build Android App
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
defaults:
run:
working-directory: RxCodeAndroid
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Write Firebase config
env:
FIREBASE_ANDROID_B64: ${{ secrets.FIREBASE_ANDROID_B64 }}
# The shared script writes RxCodeAndroid/app/google-services.json from
# the secret. Without it the build silently skips the Firebase plugins.
run: ../scripts/ci/write-firebase-config.sh
- name: Decode upload keystore
id: keystore
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
# Optional: PRs from forks won't have the secret, so the build falls
# back to debug signing (see app/build.gradle.kts). Only release events
# strictly require it (enforced below).
run: |
if [ -z "$ANDROID_KEYSTORE_BASE64" ]; then
echo "No ANDROID_KEYSTORE_BASE64 secret; release build will use debug signing."
exit 0
fi
KS_PATH="$RUNNER_TEMP/rxcode-upload.jks"
echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$KS_PATH"
echo "path=$KS_PATH" >> "$GITHUB_OUTPUT"
- name: Resolve version (release only)
if: github.event_name == 'release'
# versionName = release tag without leading 'v'; versionCode = monotonic
# CI run number so every published bundle is strictly increasing.
run: |
VERSION_NAME="${GITHUB_REF_NAME#v}"
echo "ANDROID_VERSION_NAME=${VERSION_NAME}" >> "$GITHUB_ENV"
echo "ANDROID_VERSION_CODE=${{ github.run_number }}" >> "$GITHUB_ENV"
- name: Require keystore for release
if: github.event_name == 'release' && steps.keystore.outputs.path == ''
run: |
echo "::error::ANDROID_KEYSTORE_BASE64 is required to publish a release."
exit 1
- name: Build release AAB
env:
ANDROID_KEYSTORE_PATH: ${{ steps.keystore.outputs.path }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
run: ./gradlew :app:bundleRelease --no-daemon --stacktrace
- name: Locate AAB
id: aab
run: |
AAB_PATH="$(find app/build/outputs/bundle/release -name '*.aab' | head -n1)"
if [ -z "$AAB_PATH" ]; then
echo "::error::No AAB produced."
exit 1
fi
echo "path=$(pwd)/$AAB_PATH" >> "$GITHUB_OUTPUT"
echo "Built $AAB_PATH"
# Smoke-test artifact for pushes/PRs (1 day retention)
- name: Upload AAB artifact (non-release)
if: github.event_name != 'release'
uses: actions/upload-artifact@v7
with:
name: RxCode-Android-${{ github.run_number }}
path: ${{ steps.aab.outputs.path }}
retention-days: 1
- name: Write Play service account
if: github.event_name == 'release'
env:
PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }}
run: |
if [ -z "$PLAY_SERVICE_ACCOUNT_JSON" ]; then
echo "::error::PLAY_SERVICE_ACCOUNT_JSON is required to publish to Google Play."
exit 1
fi
printf '%s' "$PLAY_SERVICE_ACCOUNT_JSON" > "$RUNNER_TEMP/play-service-account.json"
- name: Publish to Google Play (internal track)
if: github.event_name == 'release'
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: ${{ runner.temp }}/play-service-account.json
packageName: app.rxlab.rxcode
releaseFiles: ${{ steps.aab.outputs.path }}
track: internal
status: completed
- name: Attach AAB to GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v3
with:
files: ${{ steps.aab.outputs.path }}
token: ${{ secrets.GITHUB_TOKEN }}