|
| 1 | +name: Release APK |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + # Full history so we can derive a monotonic versionCode from commit count. |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Set up Node |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: '22' |
| 27 | + |
| 28 | + - name: Set up Bun |
| 29 | + uses: oven-sh/setup-bun@v2 |
| 30 | + with: |
| 31 | + bun-version: '1.2' |
| 32 | + |
| 33 | + - name: Set up JDK 17 |
| 34 | + uses: actions/setup-java@v4 |
| 35 | + with: |
| 36 | + distribution: 'temurin' |
| 37 | + java-version: '17' |
| 38 | + |
| 39 | + - name: Set up Gradle |
| 40 | + uses: gradle/actions/setup-gradle@v4 |
| 41 | + |
| 42 | + - name: Install JS dependencies |
| 43 | + run: bun install --frozen-lockfile |
| 44 | + |
| 45 | + - name: Compute version |
| 46 | + id: version |
| 47 | + run: | |
| 48 | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
| 49 | + VERSION_NAME="${GITHUB_REF_NAME#v}" |
| 50 | + else |
| 51 | + VERSION_NAME="0.0.0-dev.${GITHUB_RUN_NUMBER}" |
| 52 | + fi |
| 53 | + VERSION_CODE=$(git rev-list --count HEAD) |
| 54 | + echo "name=$VERSION_NAME" >> "$GITHUB_OUTPUT" |
| 55 | + echo "code=$VERSION_CODE" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Building $VERSION_NAME (code $VERSION_CODE)" |
| 57 | +
|
| 58 | + - name: Decode release keystore |
| 59 | + env: |
| 60 | + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} |
| 61 | + run: | |
| 62 | + echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore" |
| 63 | +
|
| 64 | + - name: Assemble release APK |
| 65 | + working-directory: android |
| 66 | + env: |
| 67 | + RELEASE_STORE_FILE: ${{ runner.temp }}/release.keystore |
| 68 | + RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} |
| 69 | + RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} |
| 70 | + RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} |
| 71 | + RELEASE_VERSION_NAME: ${{ steps.version.outputs.name }} |
| 72 | + RELEASE_VERSION_CODE: ${{ steps.version.outputs.code }} |
| 73 | + run: ./gradlew assembleRelease --no-daemon --stacktrace |
| 74 | + |
| 75 | + - name: Rename APK |
| 76 | + run: | |
| 77 | + mkdir -p artifacts |
| 78 | + cp android/app/build/outputs/apk/release/app-release.apk \ |
| 79 | + "artifacts/culpeos-${{ steps.version.outputs.name }}.apk" |
| 80 | + ls -la artifacts |
| 81 | +
|
| 82 | + - name: Upload APK as workflow artifact |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: culpeos-${{ steps.version.outputs.name }} |
| 86 | + path: artifacts/*.apk |
| 87 | + if-no-files-found: error |
| 88 | + |
| 89 | + - name: Create GitHub Release |
| 90 | + if: startsWith(github.ref, 'refs/tags/v') |
| 91 | + uses: softprops/action-gh-release@v2 |
| 92 | + with: |
| 93 | + files: artifacts/*.apk |
| 94 | + generate_release_notes: true |
| 95 | + fail_on_unmatched_files: true |
0 commit comments