|
| 1 | +name: Release Android Snapshot Helper |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + release_tag: |
| 10 | + description: GitHub Release tag to upload assets to, for example v0.13.3. |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + checkout_ref: |
| 14 | + description: Optional branch, tag, or commit SHA to build. Defaults to the selected workflow ref. |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + publish-android-snapshot-helper: |
| 23 | + name: Publish Android Snapshot Helper |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 30 |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 29 | + with: |
| 30 | + ref: ${{ github.event.inputs.checkout_ref || github.ref }} |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 34 | + with: |
| 35 | + node-version: "22" |
| 36 | + |
| 37 | + - name: Install Android SDK packages |
| 38 | + run: | |
| 39 | + yes | sdkmanager --licenses >/dev/null |
| 40 | + sdkmanager "platforms;android-36" "build-tools;36.0.0" |
| 41 | +
|
| 42 | + - name: Resolve release metadata |
| 43 | + id: meta |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | + PACKAGE_VERSION="$(node -p "JSON.parse(require('node:fs').readFileSync('package.json', 'utf8')).version")" |
| 47 | + TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.release_tag }}" |
| 48 | + VERSION="${TAG_NAME#v}" |
| 49 | + if [ "$VERSION" != "$PACKAGE_VERSION" ]; then |
| 50 | + echo "Release tag $TAG_NAME does not match package.json version $PACKAGE_VERSION" >&2 |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + echo "tag=$TAG_NAME" >> "$GITHUB_OUTPUT" |
| 54 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Package Android snapshot helper |
| 58 | + id: package |
| 59 | + env: |
| 60 | + RELEASE_ASSET_DIR: ${{ github.workspace }}/.tmp/release-assets |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + mkdir -p "${RELEASE_ASSET_DIR}" |
| 64 | + sh ./scripts/package-android-snapshot-helper.sh \ |
| 65 | + "${{ steps.meta.outputs.version }}" \ |
| 66 | + "${{ steps.meta.outputs.tag }}" \ |
| 67 | + "${RELEASE_ASSET_DIR}" |
| 68 | + shell: bash |
| 69 | + |
| 70 | + - name: Upload helper assets to GitHub Release |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ github.token }} |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + gh release upload "${{ steps.meta.outputs.tag }}" \ |
| 76 | + "${{ steps.package.outputs.apk_path }}" \ |
| 77 | + "${{ steps.package.outputs.checksum_path }}" \ |
| 78 | + "${{ steps.package.outputs.manifest_path }}" \ |
| 79 | + --clobber |
| 80 | + shell: bash |
0 commit comments