|
| 1 | +name: Build Test Harness |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version-name: |
| 7 | + description: "Optional. Version string to use, in X.Y.Z format. Overrides default in the project." |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + version-code: |
| 11 | + description: "Optional. Build number to use. Overrides default of GitHub run number." |
| 12 | + required: false |
| 13 | + type: number |
| 14 | + patch_version: |
| 15 | + description: "Order 999 - Overrides Patch version" |
| 16 | + type: boolean |
| 17 | + |
| 18 | +env: |
| 19 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + JAVA_VERSION: 21 |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + packages: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + version: |
| 28 | + name: Calculate Version Name and Number |
| 29 | + uses: bitwarden/android/.github/workflows/_version.yml@main |
| 30 | + with: |
| 31 | + app_codename: "bwth" |
| 32 | + base_version_number: 0 |
| 33 | + version_name: ${{ inputs.version-name }} |
| 34 | + version_number: ${{ inputs.version-code }} |
| 35 | + patch_version: ${{ inputs.patch_version && '999' || '' }} |
| 36 | + |
| 37 | + build: |
| 38 | + name: Build Test Harness |
| 39 | + runs-on: ubuntu-24.04 |
| 40 | + needs: version |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Log inputs to job summary |
| 44 | + uses: bitwarden/android/.github/actions/log-inputs@main |
| 45 | + with: |
| 46 | + inputs: "${{ toJson(inputs) }}" |
| 47 | + |
| 48 | + - name: Check out repo |
| 49 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 50 | + with: |
| 51 | + persist-credentials: false |
| 52 | + |
| 53 | + - name: Validate Gradle wrapper |
| 54 | + uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 |
| 55 | + |
| 56 | + - name: Cache Gradle files |
| 57 | + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 58 | + with: |
| 59 | + path: | |
| 60 | + ~/.gradle/caches |
| 61 | + ~/.gradle/wrapper |
| 62 | + key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-gradle-v2- |
| 65 | +
|
| 66 | + - name: Cache build output |
| 67 | + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 68 | + with: |
| 69 | + path: | |
| 70 | + ${{ github.workspace }}/build-cache |
| 71 | + key: ${{ runner.os }}-build-cache-${{ github.sha }} |
| 72 | + restore-keys: | |
| 73 | + ${{ runner.os }}-build- |
| 74 | +
|
| 75 | + - name: Configure JDK |
| 76 | + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 |
| 77 | + with: |
| 78 | + distribution: "temurin" |
| 79 | + java-version: ${{ env.JAVA_VERSION }} |
| 80 | + |
| 81 | + - name: Configure Ruby |
| 82 | + uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0 |
| 83 | + with: |
| 84 | + bundler-cache: true |
| 85 | + |
| 86 | + - name: Install Fastlane |
| 87 | + run: | |
| 88 | + gem install bundler:2.2.27 |
| 89 | + bundle config path vendor/bundle |
| 90 | + bundle install --jobs 4 --retry 3 |
| 91 | +
|
| 92 | + - name: Increment version |
| 93 | + env: |
| 94 | + DEFAULT_VERSION_CODE: ${{ github.run_number }} |
| 95 | + INPUT_VERSION_CODE: "${{ needs.version.outputs.version_number }}" |
| 96 | + INPUT_VERSION_NAME: ${{ needs.version.outputs.version_name }} |
| 97 | + run: | |
| 98 | + VERSION_CODE="${INPUT_VERSION_CODE:-$DEFAULT_VERSION_CODE}" |
| 99 | + VERSION_NAME_INPUT="${INPUT_VERSION_NAME:-}" |
| 100 | + bundle exec fastlane setBuildVersionInfo \ |
| 101 | + versionCode:"$VERSION_CODE" \ |
| 102 | + versionName:"$VERSION_NAME_INPUT" |
| 103 | +
|
| 104 | + regex='appVersionName = "([^"]+")' |
| 105 | + if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then |
| 106 | + VERSION_NAME="${BASH_REMATCH[1]}" |
| 107 | + fi |
| 108 | + echo "Version Name: ${VERSION_NAME}" >> "$GITHUB_STEP_SUMMARY" |
| 109 | + echo "Version Number: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY" |
| 110 | +
|
| 111 | + - name: Build Test Harness Debug APK |
| 112 | + run: ./gradlew :testharness:assembleDebug |
| 113 | + |
| 114 | + - name: Upload Test Harness APK |
| 115 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 116 | + with: |
| 117 | + name: com.bitwarden.testharness.dev-debug.apk |
| 118 | + path: testharness/build/outputs/apk/debug/com.bitwarden.testharness.dev-debug.apk |
| 119 | + if-no-files-found: error |
| 120 | + |
| 121 | + - name: Create checksum for Test Harness APK |
| 122 | + run: | |
| 123 | + sha256sum "testharness/build/outputs/apk/debug/com.bitwarden.testharness.dev-debug.apk" \ |
| 124 | + > ./com.bitwarden.testharness.dev-debug.apk-sha256.txt |
| 125 | +
|
| 126 | + - name: Upload Test Harness SHA file |
| 127 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 128 | + with: |
| 129 | + name: com.bitwarden.testharness.dev-debug.apk-sha256.txt |
| 130 | + path: ./com.bitwarden.testharness.dev-debug.apk-sha256.txt |
| 131 | + if-no-files-found: error |
0 commit comments