Skip to content

optimize: add custom request interceptor/adblocker to background WebV… #31

optimize: add custom request interceptor/adblocker to background WebV…

optimize: add custom request interceptor/adblocker to background WebV… #31

Workflow file for this run

name: Auto Release OTA Update
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Build & Release OTA Update
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Extract Version from Gradle
id: version
run: |
VERSION=$(grep "versionName" android/app/build.gradle | head -n 1 | awk -F'"' '{print $2}')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install Android SDK Packages
run: |
sdkmanager "platforms;android-36" "build-tools;36.0.0" "build-tools;35.0.0"
- name: Build Web Bundle
run: npm run build
- name: Create OTA Bundle Zip
run: |
cd dist && zip -r ../bundle.zip . && cd ..
- name: Capacitor Sync
run: npx cap sync
- name: Build Signed APK with Gradle
run: |
cd android
chmod +x gradlew
./gradlew assembleRelease
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/AniPlay.apk
cd ..
- name: Create GitHub Release and Upload Assets
id: release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: "AniPlay ${{ steps.version.outputs.version }}"
body: "OTA web bundle update + standalone release APK. Install automatically via the app or download the APK directly."
files: |
bundle.zip
android/app/build/outputs/apk/release/AniPlay.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update update.json with new version and bundle URL
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}"
BUNDLE_URL="https://github.com/SahilKumar337/AniPlay/releases/download/${TAG}/bundle.zip"
APK_URL="https://github.com/SahilKumar337/AniPlay/releases/download/${TAG}/AniPlay.apk"
python3 - <<'PYEOF'
import json, os
with open('update.json', 'r') as f:
d = json.load(f)
d['latestVersion'] = os.environ['VERSION']
d['bundleUrl'] = os.environ['BUNDLE_URL']
d['apkUrl'] = os.environ['APK_URL']
with open('update.json', 'w') as f:
json.dump(d, f, indent=2)
print('update.json updated to', d['latestVersion'])
PYEOF
env:
VERSION: ${{ steps.version.outputs.version }}
TAG: ${{ steps.version.outputs.tag }}
BUNDLE_URL: https://github.com/SahilKumar337/AniPlay/releases/download/${{ steps.version.outputs.tag }}/bundle.zip
APK_URL: https://github.com/SahilKumar337/AniPlay/releases/download/${{ steps.version.outputs.tag }}/AniPlay.apk
- name: Commit updated update.json back to repo
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add update.json
git diff --staged --quiet || git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]"
git push