Files
youtube-generator/.github/workflows/release-android.yml
T
poli0981andClaude Opus 5.5 1b5051beaa ci: keep release builds off the npm cache; week-long Dependabot cooldown
zizmor (workflow-lint) flagged three things:

- cache-poisoning: setup-node v7 restores the npm cache unless told not
  to, and the release workflows publish what they build. They now set
  `package-manager-cache: false`, so a cache written by another workflow
  can never reach a release artifact.
- dependabot-cooldown: raise every ecosystem to 7 days.
- dangerous-triggers: the two `workflow_run` notifiers are ignored with
  the reason in zizmor.yml; the shared workflows only read run metadata
  and pass untrusted fields through `env:`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 20:00:55 +07:00

139 lines
5.4 KiB
YAML

name: Release Android
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Tag to build (e.g. v1.0.0). The manifests must already carry this version."
required: true
type: string
permissions:
contents: read
jobs:
# Same gate as release-desktop.yml: never sign an APK for a tag whose code
# fails the checks or whose version fields disagree with the tag.
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.inputs.tag || github.ref }}
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
# Release artifacts are built from a clean install: a cache written
# by any other workflow must not be able to feed into them.
package-manager-cache: false
- run: npm ci
- run: npm run typecheck
- run: npm run test:run
- run: npm run check:version
- run: npm run check:tauri
- name: Tag matches the manifests
env:
TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: |
version="v$(node -p "require('./package.json').version")"
if [ "$version" != "$TAG" ]; then
echo "::error::Tag $TAG does not match package.json ($version)"
exit 1
fi
build-android:
needs: verify
runs-on: ubuntu-latest
permissions:
contents: write # upload the APK to the draft release
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.inputs.tag || github.ref }}
persist-credentials: false
# No dependency caches in a release job (see release-desktop.yml).
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
# Release artifacts are built from a clean install: a cache written
# by any other workflow must not be able to feed into them.
package-manager-cache: false
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: "17"
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
- name: Install Android NDK (r27 LTS)
run: sdkmanager "ndk;27.3.13750724"
- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
toolchain: stable
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
- run: npm ci
- name: Install Tauri CLI
run: cargo install tauri-cli --version "^2" --locked
- name: Decode keystore
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
run: echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.jks"
- name: Write keystore.properties
env:
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
run: |
{
echo "storeFile=$RUNNER_TEMP/release.jks"
echo "storePassword=$ANDROID_STORE_PASSWORD"
echo "keyAlias=$ANDROID_KEY_ALIAS"
echo "keyPassword=$ANDROID_KEY_PASSWORD"
} > src-tauri/gen/android/keystore.properties
- name: Build signed APK
env:
# Pin NDK_HOME to the exact version we installed above — the runner may
# ship a different default NDK that ANDROID_NDK_ROOT would point at.
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.3.13750724
run: cargo tauri android build --apk
# Keep the APK regardless of whether the release upload works, so a
# broken upload never costs a 20-minute rebuild.
- name: Upload APK as workflow artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ytdescgen-android-apk
path: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
if-no-files-found: error
# Uses `gh` (pre-installed on every runner) rather than a third-party
# action. `softprops/action-gh-release@v3` resolved the target release
# from GITHUB_REF instead of the `tag_name` it was given, so on a tag push
# it looked for a release tagged `refs/tags/v0.35.0` and on a
# workflow_dispatch it looked for one tagged `refs/heads/main` — neither
# exists, so it tried to CREATE a release on a branch ref and got
# "Resource not accessible by integration". The v0.35.0 APK was built
# three times before this was pinned down.
#
# `gh release upload` takes the tag as a positional argument and cannot
# make that mistake. `--clobber` makes a re-run idempotent.
- name: Upload APK to draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.inputs.tag || github.ref_name }}
REPO: ${{ github.repository }}
APK: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
run: |
gh release upload "$TAG" "$APK" --clobber --repo "$REPO"