forked from betaflight/betaflight-configurator
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (122 loc) · 4.59 KB
/
build.yml
File metadata and controls
138 lines (122 loc) · 4.59 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
128
129
130
131
132
133
134
135
136
137
138
name: 'Build'
on:
workflow_call:
# 📌 1. DEFINE INPUTS THE WORKFLOW ACCEPTS
inputs:
commit_ref:
description: 'The git SHA to checkout'
required: true
type: string
debug_build:
description: 'Specifies if it is a debug build or a release build'
default: true
required: false
type: boolean
# 📌 2. DEFINE SECRETS THE WORKFLOW ACCEPTS
secrets:
RELEASE_KEYSTORE:
description: 'Base64 encoded keystore file.'
required: true
RELEASE_KEYSTORE_PASSWORD:
description: 'Keystore password.'
required: true
# Add all other signing secrets here...
RELEASE_KEY_ALIAS:
description: 'Key alias.'
required: true
RELEASE_KEY_ALIAS_PASSWORD:
description: 'Key alias password.'
required: true
# 🌟 3. DEFINE OUTPUTS THE WORKFLOW PRODUCES
outputs:
apk_url:
description: 'URL to the uploaded APK artifact'
value: ${{ jobs.build.outputs.apk_url }}
apk_name:
description: 'Name of the APK file'
value: ${{ jobs.build.outputs.apk_name }}
jobs:
build:
runs-on: ubuntu-latest
# 🌟 Define the outputs for the entire job
outputs:
apk_url: ${{ steps.apk_upload.outputs.artifact-url }}
apk_name: ${{ steps.apk_name_set.outputs.apk_name }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ inputs.commit_ref }}
persist-credentials: false # Don't persist GitHub token
- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules/
key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install node.js
uses: actions/setup-node@v5
with:
node-version-file: '.nvmrc'
- run: npm install yarn -g
- run: yarn install
- run: yarn build
- name: Generate Capacitor Config
run: node capacitor.config.generator.mjs
- name: Sync Capacitor Android Project
run: npx cap sync android
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: gradle
- name: Build and Sign Android APK
env:
RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE }}
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_ALIAS_PASSWORD: ${{ secrets.RELEASE_KEY_ALIAS_PASSWORD }}
run: |
: "${RELEASE_KEYSTORE_BASE64:?Set the RELEASE_KEYSTORE secret with your base64-encoded keystore}"
: "${RELEASE_KEYSTORE_PASSWORD:?Set the RELEASE_KEYSTORE_PASSWORD secret with your keystore password}"
: "${RELEASE_KEY_ALIAS:?Set the RELEASE_KEY_ALIAS secret with your key alias}"
: "${RELEASE_KEY_ALIAS_PASSWORD:?Set the RELEASE_KEY_ALIAS_PASSWORD secret with your key alias password}"
mkdir -p android/keystore
echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > android/keystore/release.jks
pushd android >/dev/null
./gradlew clean
./gradlew assembleRelease \
-Pandroid.injected.signing.store.file="$PWD/keystore/release.jks" \
-Pandroid.injected.signing.store.password="$RELEASE_KEYSTORE_PASSWORD" \
-Pandroid.injected.signing.key.alias="$RELEASE_KEY_ALIAS" \
-Pandroid.injected.signing.key.password="$RELEASE_KEY_ALIAS_PASSWORD"
popd >/dev/null
- name: Set APK name
id: apk_name_set
env:
IS_DEBUG: ${{ inputs.debug_build }}
run: |
VERSION=$(jq -r '.version' package.json)
mkdir -p artifacts
if [[ "$IS_DEBUG" == "true" ]]; then
echo "--- DEBUG MODE ---"
SHA=$(echo ${{ github.event.pull_request.head.sha }} | head -c 8)
apk_name=betaflight-app-$VERSION-$SHA.apk
else
echo "--- RELEASE MODE ---"
apk_name=betaflight-app-$VERSION.apk
fi
cp android/app/build/outputs/apk/release/app-release.apk artifacts/$apk_name
echo "apk_name=$apk_name" >> $GITHUB_OUTPUT
- name: Upload APK as Artifact
id: apk_upload
uses: actions/upload-artifact@v4
with:
name: betaflight-app-apk
path: artifacts/${{ steps.apk_name_set.outputs.apk_name }}
- name: Upload build artifact
id: dist_upload
uses: actions/upload-artifact@v4
with:
name: dist-files
path: src/dist