-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (167 loc) · 5.98 KB
/
android_build_ubdiag_upload.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build and Upload to UBDiag
on:
workflow_call:
inputs:
projectKey:
type: string
required: true
app:
type: string
required: true
flavor:
type: string
required: true
appModule:
type: string
required: false
default: 'app'
concurrencyGroup:
type: string
required: false
default: ${{ github.workflow }}-${{ github.ref }}
workingDirectory:
type: string
default: './'
required: false
description: 'The working directory of the script, for projects where the gradle project is not in the root folder. Must end with a slash.'
self_hosted_cache_endpoint:
required: false
default: 'truenas.local.lan'
type: string
description: Should be set for selfhosted builds, but build won't fail without it
self_hosted_cache_port:
required: false
default: 9001
type: number
self_hosted_cache_bucket:
required: false
default: github-actions-cache
type: string
self_hosted_cache_region:
required: false
default: local
type: string
setup_rust_tool_chain:
required: false
default: false
type: boolean
runs-on:
type: string
required: false
default: '["k8s-runner"]'
secrets:
ANDROID_JENKINS_PAT:
required: true
UB_ARTIFACTORY_URL_ANDROID:
required: true
UB_ARTIFACTORY_USER:
required: true
UB_ARTIFACTORY_PASSWORD:
required: true
UBIQUE_POEDITOR_API_KEY:
required: false
UBDIAG_UPLOAD_URL:
required: true
ADDITIONAL_GRADLE_PROPS:
required: false
SENTRY_AUTH_TOKEN:
required: false
self_hosted_cache_access_key:
required: false
description: Must be set to use selfhosted cache
self_hosted_cache_secret_key:
required: false
jobs:
build:
name: Build ${{ inputs.flavor }} Flavor
runs-on: ${{ fromJSON(inputs.runs-on) }}
container:
image: cimg/android:2024.04.1-ndk
defaults:
run:
working-directory: ${{ inputs.workingDirectory }}
timeout-minutes: 60
concurrency:
# Cancel any previous runs that have not yet finished for the configured concurrency group
group: ${{ inputs.concurrencyGroup }}
cancel-in-progress: true
steps:
# Checkout repository and submodules
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.ANDROID_JENKINS_PAT }}
submodules: 'recursive'
lfs: 'true'
# Set build variables for reuse in multiple steps
- name: Set Build Variables
id: vars
shell: bash
run: |
flavor=${{ inputs.flavor }}
buildUuid=$(cat /proc/sys/kernel/random/uuid)
webIconPath=$GITHUB_WORKSPACE/${{ inputs.workingDirectory }}/${{ inputs.appModule }}/tmp_icon_large_for_backend.png
echo "build_uuid=$buildUuid" >> "$GITHUB_OUTPUT"
echo "web_icon=$webIconPath" >> "$GITHUB_OUTPUT"
echo "flavor_capitalized=${flavor~}" >> "$GITHUB_OUTPUT"
# Setup JDK environment
- name: Set up JDK
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: '17'
- name: Install zstd
run: sudo apt-get install -y zstd
- name: Cache Gradle packages on self-hosted MinIO
uses: tespkg/[email protected]
if: false # Disabled for now to test if it's faster without it
with:
endpoint: ${{ inputs.self_hosted_cache_endpoint }}
port: ${{ inputs.self_hosted_cache_port }}
insecure: true
accessKey: ${{ secrets.self_hosted_cache_access_key }}
secretKey: ${{ secrets.self_hosted_cache_secret_key }}
bucket: ${{ inputs.self_hosted_cache_bucket }}
region: ${{ inputs.self_hosted_cache_region }}
use-fallback: true
path: |
~/.gradle/caches
~/.gradle/wrapper
key: cimg-android-${{ inputs.projectKey }}-${{inputs.flavor}}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
cimg-android-${{ inputs.projectKey }}-gradle-
# Setup rust Tool Chain
- name: Setup rust Tool Chain
uses: actions-rust-lang/[email protected]
if: ${{ inputs.setup_rust_tool_chain }}
# Setup the build environment with Gradle
- name: Build app
uses: gradle/actions/[email protected]
with:
cache-disabled: true
build-root-directory: ${{ inputs.workingDirectory }}
arguments: |
:${{ inputs.appModule }}:clean :${{ inputs.appModule }}:assemble${{ steps.vars.outputs.flavor_capitalized }}Release
-PubiqueMavenUrl=${{ secrets.UB_ARTIFACTORY_URL_ANDROID }}
-PubiqueMavenUser=${{ secrets.UB_ARTIFACTORY_USER }}
-PubiqueMavenPass=${{ secrets.UB_ARTIFACTORY_PASSWORD }}
-PubiquePoEditorAPIKey=${{ secrets.UBIQUE_POEDITOR_API_KEY }}
-Pbranch=${{ github.ref_name }}
-Pbuildnumber=${{ github.run_number }}
-Pubappid=${{ steps.vars.outputs.build_uuid }}
-Pwebicon=${{ steps.vars.outputs.web_icon }}
${{ secrets.ADDITIONAL_GRADLE_PROPS }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# Upload to UBDiag
- name: Upload build to UBDiag
uses: UbiqueInnovation/[email protected]
with:
buildNumber: ${{ github.run_number }}
projectKey: ${{ inputs.projectKey }}
flavor: ${{ inputs.flavor }}
app: ${{ inputs.app }}
appModuleDirectory: '${{ inputs.workingDirectory }}${{ inputs.appModule }}'
buildUuid: ${{ steps.vars.outputs.build_uuid }}
webIconFile: tmp_icon_large_for_backend.png
backendEndpoint: ${{ secrets.UBDIAG_UPLOAD_URL }}