|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + cancel-in-progress: false |
| 9 | + |
| 10 | +env: |
| 11 | + TERM: xterm-256color |
| 12 | + FORCE_COLOR: 1 |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-release: |
| 16 | + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v') |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 45 |
| 19 | + environment: release |
| 20 | + |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: read |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v6 |
| 28 | + |
| 29 | + - name: Setup Java |
| 30 | + uses: actions/setup-java@v5 |
| 31 | + with: |
| 32 | + java-version: '17' |
| 33 | + distribution: 'adopt' |
| 34 | + |
| 35 | + - name: Setup Gradle |
| 36 | + uses: gradle/actions/setup-gradle@v5 |
| 37 | + |
| 38 | + - name: Decode mainnet release google-services.json |
| 39 | + env: |
| 40 | + MAINNET_RELEASE_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.MAINNET_RELEASE_GOOGLE_SERVICES_JSON_BASE64 }} |
| 41 | + run: | |
| 42 | + set -euo pipefail |
| 43 | + test -n "$MAINNET_RELEASE_GOOGLE_SERVICES_JSON_BASE64" |
| 44 | + mkdir -p app/src/mainnetRelease |
| 45 | + printf '%s' "$MAINNET_RELEASE_GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > app/src/mainnetRelease/google-services.json |
| 46 | +
|
| 47 | + - name: Decode release keystore |
| 48 | + env: |
| 49 | + BITKIT_KEYSTORE_BASE64: ${{ secrets.BITKIT_KEYSTORE_BASE64 }} |
| 50 | + run: | |
| 51 | + set -euo pipefail |
| 52 | + test -n "$BITKIT_KEYSTORE_BASE64" |
| 53 | + umask 077 |
| 54 | + keystore_path="$RUNNER_TEMP/bitkit.keystore" |
| 55 | + printf '%s' "$BITKIT_KEYSTORE_BASE64" | base64 --decode > "$keystore_path" |
| 56 | + echo "KEYSTORE_FILE=$keystore_path" >> "$GITHUB_ENV" |
| 57 | +
|
| 58 | + - name: Build release artifacts |
| 59 | + env: |
| 60 | + GPR_USER: ${{ secrets.GPR_USER || github.actor }} |
| 61 | + GPR_TOKEN: ${{ secrets.GPR_TOKEN || github.token }} |
| 62 | + GITHUB_TOKEN: ${{ secrets.GPR_TOKEN || github.token }} |
| 63 | + KEYSTORE_PASSWORD: ${{ secrets.BITKIT_KEYSTORE_PASSWORD }} |
| 64 | + KEY_ALIAS: ${{ secrets.BITKIT_KEY_ALIAS }} |
| 65 | + KEY_PASSWORD: ${{ secrets.BITKIT_KEY_PASSWORD }} |
| 66 | + run: ./gradlew assembleMainnetRelease bundleMainnetRelease --no-daemon --stacktrace |
| 67 | + |
| 68 | + - name: Verify release signatures |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + android_sdk_root="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}" |
| 72 | + test -n "$android_sdk_root" |
| 73 | + apksigner_path="$(find "$android_sdk_root/build-tools" -name apksigner -type f | sort -V | tail -n 1)" |
| 74 | + test -n "$apksigner_path" |
| 75 | +
|
| 76 | + apk_count=0 |
| 77 | + while IFS= read -r -d '' apk_path; do |
| 78 | + apk_count=$((apk_count + 1)) |
| 79 | + "$apksigner_path" verify --verbose --print-certs "$apk_path" |
| 80 | + done < <(find app/build/outputs/apk/mainnet/release -name 'bitkit-mainnet-release-*.apk' -print0) |
| 81 | + test "$apk_count" -gt 0 |
| 82 | +
|
| 83 | + bundle_count=0 |
| 84 | + while IFS= read -r -d '' bundle_path; do |
| 85 | + bundle_count=$((bundle_count + 1)) |
| 86 | + verify_output="$(mktemp)" |
| 87 | + if ! jarsigner -verify -verbose -certs "$bundle_path" 2>&1 | tee "$verify_output"; then |
| 88 | + rm -f "$verify_output" |
| 89 | + exit 1 |
| 90 | + fi |
| 91 | + if grep -qi "jar is unsigned" "$verify_output"; then |
| 92 | + echo "Unsigned bundle: $bundle_path" |
| 93 | + rm -f "$verify_output" |
| 94 | + exit 1 |
| 95 | + fi |
| 96 | + if ! grep -qi "jar verified" "$verify_output"; then |
| 97 | + echo "Bundle signature verification did not report success: $bundle_path" |
| 98 | + rm -f "$verify_output" |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | + rm -f "$verify_output" |
| 102 | + done < <(find app/build/outputs/bundle/mainnetRelease -name 'bitkit-mainnet-release-*.aab' -print0) |
| 103 | + test "$bundle_count" -gt 0 |
| 104 | +
|
| 105 | + - name: Collect release artifacts |
| 106 | + id: artifacts |
| 107 | + run: | |
| 108 | + set -euo pipefail |
| 109 | + artifact_dir="$RUNNER_TEMP/release" |
| 110 | + mkdir -p "$artifact_dir" |
| 111 | + find app/build/outputs/bundle/mainnetRelease -name 'bitkit-mainnet-release-*.aab' -print0 | |
| 112 | + xargs -0 -I {} cp {} "$artifact_dir/" |
| 113 | + find app/build/outputs/apk/mainnet/release -name 'bitkit-mainnet-release-*.apk' -print0 | |
| 114 | + xargs -0 -I {} cp {} "$artifact_dir/" |
| 115 | + (cd "$artifact_dir" && sha256sum *.aab *.apk > SHA256SUMS.txt) |
| 116 | + echo "artifact_dir=$artifact_dir" >> "$GITHUB_OUTPUT" |
| 117 | +
|
| 118 | + - name: Upload release artifacts |
| 119 | + uses: actions/upload-artifact@v6 |
| 120 | + with: |
| 121 | + name: bitkit-release-${{ github.run_number }} |
| 122 | + path: ${{ steps.artifacts.outputs.artifact_dir }} |
| 123 | + retention-days: 30 |
0 commit comments