Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/build-tester-apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Build unsigned apk

on:
workflow_dispatch:
inputs:
build_flavor:
description: "Flavor to build"
type: choice
required: true
default: "qa"
options:
- qa
build_type:
description: "Type to build"
type: choice
required: true
default: "Debug" # uppercase for gradlew clean assembleqaDebug
options:
- Debug
version:
description: "Version to build (commit, branch or tag)"
type: string
default: "main"

permissions:
contents: write

jobs:
build_apk:
name: Build unsigned APK
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.set_artifact.outputs.artifact_name }}
commit_hash: ${{ steps.commit.outputs.commit_hash }}

steps:
- name: Checkout current repo
uses: actions/checkout@v5
with:
ref: ${{ inputs.version }}

- name: Get commit hash
id: commit
run: |
COMMIT_HASH=$(git rev-parse HEAD)
echo "Commit hash: $COMMIT_HASH"
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT

- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build APK
run: ./gradlew clean assemble${{ inputs.build_flavor }}${{ inputs.build_type }} -PversionCode=${{ github.run_number }}

- name: Set artifact name
id: set_artifact
run: |
DATE=$(date +%Y%m%d_%H%M)
COMMIT=$(git rev-parse --short HEAD)
FLAVOR="${{ inputs.build_flavor }}"
BUILD_TYPE="debug"
NAME="OpenCloud-${{ inputs.build_flavor }}-${COMMIT}-${DATE}-${GITHUB_RUN_NUMBER}.apk"

APK_PATH=$(find ./opencloudApp/build/outputs/apk/$FLAVOR/$BUILD_TYPE/ -name "*.apk")

echo "$APK_PATH"
if [ -z "$APK_PATH" ]; then
echo "APK not found"
exit 1
fi

cp "$APK_PATH" "./$NAME"
echo "$NAME"

# Publish as output
echo "artifact_name=$NAME" >> $GITHUB_OUTPUT

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_artifact.outputs.artifact_name }}
path: ./${{ steps.set_artifact.outputs.artifact_name }}
compression-level: 0

- name: Upload APK to release
uses: softprops/action-gh-release@v2
with:
tag_name: build-tester-apk-${{ github.run_number }}
name: build-tester-apk build ${{ github.run_number }}
files: ${{ steps.set_artifact.outputs.artifact_name }}
prerelease: true
17 changes: 17 additions & 0 deletions opencloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ android {

buildConfigField "String", gitRemote, "\"" + getGitOriginRemote() + "\""
buildConfigField "String", commitSHA1, "\"" + getLatestGitHash() + "\""

// 2. If the caller (GitHub) provided a specific number, overwrite the versionCode.
if (project.hasProperty('versionCode')) {
versionCode project.property('versionCode').toInteger()
}
}

compileOptions {
Expand Down Expand Up @@ -160,6 +165,18 @@ android {
//mdm {
// dimension "management"
//}
qa {
dimension "management"
applicationIdSuffix ".qa"
// replace stuff from setup.xml
resValue "string", "app_name", "OpenCloud QA"
resValue "string", "account_type", "eu.opencloud.qa"
resValue "string", "authority", "eu.opencloud.qa"
resValue "string", "document_provider_authority", "eu.opencloud.qa.documents"
resValue "string", "file_provider_authority", "eu.opencloud.qa.files"
resValue "string", "search_suggest_authority", "eu.opencloud.qa.search.users_and_groups"
resValue "string", "search_suggest_intent_action", "eu.opencloud.qa.search.users_and_groups.action.SHARE_WITH"
}
}

applicationVariants.all { variant ->
Expand Down
Loading