Skip to content

Commit d2a8663

Browse files
committed
Github: New action to build unsigned APK for testing
Have it be a different app with different application ID so that it can be installed next to the normal release.
1 parent 03048de commit d2a8663

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build unsigned apk
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
build_flavor:
7+
description: "Flavor to build"
8+
type: choice
9+
required: true
10+
default: "qa"
11+
options:
12+
- qa
13+
build_type:
14+
description: "Type to build"
15+
type: choice
16+
required: true
17+
default: "Debug" # uppercase for gradlew clean assembleqaDebug
18+
options:
19+
- Debug
20+
version:
21+
description: "Version to build (commit, branch or tag)"
22+
type: string
23+
default: "main"
24+
25+
permissions:
26+
contents: write
27+
28+
jobs:
29+
build_apk:
30+
name: Build unsigned APK
31+
runs-on: ubuntu-latest
32+
outputs:
33+
artifact_name: ${{ steps.set_artifact.outputs.artifact_name }}
34+
commit_hash: ${{ steps.commit.outputs.commit_hash }}
35+
36+
steps:
37+
- name: Checkout current repo
38+
uses: actions/checkout@v5
39+
with:
40+
ref: ${{ inputs.version }}
41+
42+
- name: Get commit hash
43+
id: commit
44+
run: |
45+
COMMIT_HASH=$(git rev-parse HEAD)
46+
echo "Commit hash: $COMMIT_HASH"
47+
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
48+
49+
- name: Setup JDK
50+
uses: actions/setup-java@v5
51+
with:
52+
distribution: 'temurin'
53+
java-version: '17'
54+
55+
- name: Cache Gradle
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/.gradle/caches
60+
~/.gradle/wrapper
61+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
62+
restore-keys: |
63+
${{ runner.os }}-gradle-
64+
65+
- name: Build APK
66+
run: ./gradlew clean assemble${{ inputs.build_flavor }}${{ inputs.build_type }} -PversionCode=${{ github.run_number }}
67+
68+
- name: Set artifact name
69+
id: set_artifact
70+
run: |
71+
DATE=$(date +%Y%m%d_%H%M)
72+
COMMIT=$(git rev-parse --short HEAD)
73+
FLAVOR="${{ inputs.build_flavor }}"
74+
BUILD_TYPE="debug"
75+
NAME="OpenCloud-${{ inputs.build_flavor }}-${COMMIT}-${DATE}-${GITHUB_RUN_NUMBER}.apk"
76+
77+
APK_PATH=$(find ./opencloudApp/build/outputs/apk/$FLAVOR/$BUILD_TYPE/ -name "*.apk")
78+
79+
echo "$APK_PATH"
80+
if [ -z "$APK_PATH" ]; then
81+
echo "APK not found"
82+
exit 1
83+
fi
84+
85+
cp "$APK_PATH" "./$NAME"
86+
echo "$NAME"
87+
88+
# Publish as output
89+
echo "artifact_name=$NAME" >> $GITHUB_OUTPUT
90+
91+
- name: Upload artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: ${{ steps.set_artifact.outputs.artifact_name }}
95+
path: ./${{ steps.set_artifact.outputs.artifact_name }}
96+
compression-level: 0
97+
98+
- name: Upload APK to release
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
tag_name: build-tester-apk-${{ github.run_number }}
102+
name: build-tester-apk build ${{ github.run_number }}
103+
files: ${{ steps.set_artifact.outputs.artifact_name }}
104+
prerelease: true

opencloudApp/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ android {
105105

106106
buildConfigField "String", gitRemote, "\"" + getGitOriginRemote() + "\""
107107
buildConfigField "String", commitSHA1, "\"" + getLatestGitHash() + "\""
108+
109+
// 2. If the caller (GitHub) provided a specific number, overwrite the versionCode.
110+
if (project.hasProperty('versionCode')) {
111+
versionCode project.property('versionCode').toInteger()
112+
}
108113
}
109114

110115
compileOptions {
@@ -160,6 +165,18 @@ android {
160165
//mdm {
161166
// dimension "management"
162167
//}
168+
qa {
169+
dimension "management"
170+
applicationIdSuffix ".qa"
171+
// replace stuff from setup.xml
172+
resValue "string", "app_name", "OpenCloud QA"
173+
resValue "string", "account_type", "eu.opencloud.qa"
174+
resValue "string", "authority", "eu.opencloud.qa"
175+
resValue "string", "document_provider_authority", "eu.opencloud.qa.documents"
176+
resValue "string", "file_provider_authority", "eu.opencloud.qa.files"
177+
resValue "string", "search_suggest_authority", "eu.opencloud.qa.search.users_and_groups"
178+
resValue "string", "search_suggest_intent_action", "eu.opencloud.qa.search.users_and_groups.action.SHARE_WITH"
179+
}
163180
}
164181

165182
applicationVariants.all { variant ->

0 commit comments

Comments
 (0)