Files
moeka-project/.github/workflows/release-pocket-android.yml
T
Lovehsigure_520 65751f598d chore(ci): mirror release assets to GitCode (#1797)
## Summary

Adds GitCode Release mirroring for AIRI release assets.

- Adds a reusable `.github/scripts/publish-gitcode-release.sh` helper
that creates or reuses the matching GitCode release, compares GitHub and
GitCode asset names, downloads only missing `AIRI-*` and `latest-*.yml`
assets, uploads them through GitCode's upload URL API, and verifies the
final asset list.
- Hooks the mirror step into desktop, Android, and iOS release workflows
so assets produced by separate release jobs can converge on the same
GitCode release.
- Keeps the mirror idempotent so repeated or concurrent release
workflows skip already mirrored files.

## Why

GitHub Releases are slow for many mainland China users. GitCode provides
a domestic fallback release page, but manually copying installers after
every release is error-prone and tedious.

## Validation

- `bash -n .github/scripts/publish-gitcode-release.sh`
- YAML parsing for:
  - `.github/workflows/release-tamagotchi.yml`
  - `.github/workflows/release-pocket-android.yml`
  - `.github/workflows/release-pocket-ios.yml`
- `git diff --check -- .github/scripts/publish-gitcode-release.sh
.github/workflows/release-tamagotchi.yml
.github/workflows/release-pocket-android.yml
.github/workflows/release-pocket-ios.yml`
- Local idempotency check against existing `v0.10.1` GitHub/GitCode
releases:
  - GitCode release already exists
  - all mirrored assets already present
  - final asset verification passed

## Setup Required

The target repository needs these GitHub Secrets:

- `GITCODE_TOKEN`
- `GITCODE_OWNER`
- `GITCODE_REPO`

For the current GitCode project, `GITCODE_OWNER` should remain `MoeruAI`
because GitCode's API and release download paths currently resolve that
namespace even though the UI displays `moeru-ai`.
2026-05-19 21:49:26 +08:00

139 lines
5.0 KiB
YAML

name: Release Pocket (Android)
permissions:
contents: write
actions: read
on:
release:
types:
- prereleased
workflow_dispatch:
inputs:
build_only:
description: Build only (no upload to release)
required: false
default: false
type: boolean
tag:
description: Specific tag for the release upload
required: false
type: string
schedule:
- cron: '0 1 * * *'
jobs:
build:
name: Build Android APK
runs-on: ubuntu-latest
env:
PRODUCT_NAME: 'AIRI'
# Every current trigger path produces an installable APK artifact, so ship the analytics-enabled build consistently.
VITE_ENABLE_POSTHOG: 'true'
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v6
with:
node-version: lts/*
cache: pnpm
- name: Install Android build tools
run: |
sdkmanager "build-tools;36.1.0"
echo "${ANDROID_SDK_ROOT:-$ANDROID_HOME}/build-tools/36.1.0" >> "$GITHUB_PATH"
- run: pnpm install --frozen-lockfile
- run: pnpm run build:packages
- name: Validate workflow dispatch release tag
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.tag == '' }}
run: |
echo "workflow_dispatch release uploads require the tag input"
exit 1
- name: Build web assets
run: pnpm -F @proj-airi/stage-pocket run build
- name: Capacitor sync
run: pnpm -F @proj-airi/stage-pocket exec cap sync android
- name: Extract android keystore
run: echo "${{ secrets.CAPACITOR_ANDROID_KEYSTORE_BASE64 }}" | base64 -d > ${{ github.workspace }}/apps/stage-pocket/airi-pocket.jks
- name: Build APK
working-directory: apps/stage-pocket/android
run: pnpm -F @proj-airi/stage-pocket exec cap build android
env:
CAPACITOR_ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/apps/stage-pocket/airi-pocket.jks
CAPACITOR_ANDROID_KEYSTORE_ALIAS: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_ALIAS }}
CAPACITOR_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_PASSWORD }}
CAPACITOR_ANDROID_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_ALIAS_PASSWORD }}
- name: Rename APK for distribution
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name || inputs.tag }}
run: |
VERSION="${RELEASE_TAG_NAME#v}"
if [ -z "$VERSION" ]; then
VERSION="$(sed -n 's/^AIRI_VERSION_NAME=//p' apps/stage-pocket/android/app-version.properties)"
fi
APK_NAME="${PRODUCT_NAME}-${VERSION}-android.apk"
APK_SOURCE="apps/stage-pocket/android/app/build/outputs/apk/release/app-release-signed.apk"
APK_BUNDLE_DIR="apps/stage-pocket/android/bundle"
mkdir -p "$APK_BUNDLE_DIR"
mv "$APK_SOURCE" "$APK_BUNDLE_DIR/$APK_NAME"
echo "APK_NAME=$APK_NAME" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.APK_NAME }}
path: apps/stage-pocket/android/bundle/${{ env.APK_NAME }}
if-no-files-found: error
- name: Upload to GitHub Releases
id: upload-github-release
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.build_only) }}
uses: softprops/action-gh-release@v2
with:
files: apps/stage-pocket/android/bundle/${{ env.APK_NAME }}
append_body: true
tag_name: ${{ github.event.release.tag_name || inputs.tag }}
- name: Setup butler
uses: remarkablegames/setup-butler@v2
# https://itch.io/docs/butler/pushing.html
- name: Upload Android to itch.io
if: ${{ github.event_name == 'release' }}
run: butler push apps/stage-pocket/android/bundle/${{ env.APK_NAME }} nekomeowww/airi:android --userversion ${{ env.VERSION }}
env:
BUTLER_API_KEY: ${{ secrets.GAME_PUBLISHING_ITCHIO }}
- name: Publish release assets to GitCode
if: ${{ always() && github.repository == 'moeru-ai/airi' && steps.upload-github-release.outcome == 'success' && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.build_only)) }}
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
GITCODE_OWNER: ${{ secrets.GITCODE_OWNER }}
GITCODE_REPO: ${{ secrets.GITCODE_REPO }}
GITCODE_RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: bash .github/scripts/publish-gitcode-release.sh