-
Notifications
You must be signed in to change notification settings - Fork 64
70 lines (66 loc) · 2.09 KB
/
android-build-sample.yml
File metadata and controls
70 lines (66 loc) · 2.09 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
name: Build Android Sample App
on:
workflow_dispatch:
inputs:
api_key:
description: 'API Key'
required: true
type: string
api_url:
description: 'API URL'
required: true
type: string
env:
JAVA_VERSION: 21
JAVA_DISTRIBUTION: 'temurin'
jobs:
validate-inputs:
name: Validate inputs
permissions: {}
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Validate API Key
run: |
if [[ ! "${{ inputs.api_key }}" =~ ^msrsh ]]; then
echo "::error::API Key must start with 'msrsh'"
exit 1
fi
build-sample:
name: Build sample APK
needs: validate-inputs
runs-on: ubuntu-latest
defaults:
run:
working-directory: android
permissions:
contents: read
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'
- name: Set credentials in AndroidManifest.xml
env:
API_KEY: ${{ inputs.api_key }}
API_URL: ${{ inputs.api_url }}
run: |
sed -i '/android:name="sh.measure.android.API_KEY"/{n;s|android:value="[^"]*"|android:value="'"$API_KEY"'"|;}' sample/src/main/AndroidManifest.xml
sed -i '/android:name="sh.measure.android.API_URL"/{n;s|android:value="[^"]*"|android:value="'"$API_URL"'"|;}' sample/src/main/AndroidManifest.xml
- name: Build release APK
run: ./gradlew :sample:assembleRelease --no-daemon --no-parallel --no-configuration-cache --stacktrace --info
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: sample-release-apk
path: android/sample/build/outputs/apk/release/*.apk
retention-days: 7
- name: Upload mapping file
uses: actions/upload-artifact@v4
with:
name: sample-release-mapping
path: android/sample/build/outputs/mapping/release/mapping.txt
retention-days: 7