From 1b8308d441ec309314c25f5e439463df1d1c386b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 27 Jan 2026 13:07:11 +0100 Subject: [PATCH] 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. --- .github/workflows/build-tester-apk.yml | 104 +++++++++++++++++++++++++ opencloudApp/build.gradle | 17 ++++ 2 files changed, 121 insertions(+) create mode 100644 .github/workflows/build-tester-apk.yml diff --git a/.github/workflows/build-tester-apk.yml b/.github/workflows/build-tester-apk.yml new file mode 100644 index 000000000..2c40ee95a --- /dev/null +++ b/.github/workflows/build-tester-apk.yml @@ -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 diff --git a/opencloudApp/build.gradle b/opencloudApp/build.gradle index bea57398d..8f88d9479 100644 --- a/opencloudApp/build.gradle +++ b/opencloudApp/build.gradle @@ -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 { @@ -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 ->