Build unsigned apk #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| echo "commit_hash=$COMMIT_HASH" >> "$GITHUB_ENV" | |
| - 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 }} | |
| target_commitish: ${{ env.commit_hash }} | |
| name: build-tester-apk build ${{ github.run_number }} | |
| files: ${{ steps.set_artifact.outputs.artifact_name }} | |
| prerelease: true | |
| generate_release_notes: false | |
| body: Built from ${{ env.commit_hash }} |