Files
rl-mobile/.github/workflows/release.yml
T
2026-08-14 16:55:27 +00:00

95 lines
3.5 KiB
YAML

name: "[main] Release"
on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
# Lets a release be re-run by hand from the Actions tab if a push event is ever missed.
workflow_dispatch:
jobs:
Version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: set
run: |
# .version now holds the full semver (e.g. 1.0.0) and is bumped per release.
# It used to be a "0.3" prefix with github.run_number appended as the patch,
# which cannot express an exact 1.0.0. versionCode still tracks run_number,
# so it stays monotonic regardless of what versionName says.
BASE=$(cat .version | tr -d '[:space:]')
echo "version=$BASE" >> $GITHUB_OUTPUT
# Releasing onto an existing tag silently overwrites that release's assets, so a
# forgotten .version bump replaces history instead of publishing. Fail loudly instead.
# ls-remote, not rev-parse: actions/checkout does not fetch tags by default,
# so a local lookup would always miss and the guard would never fire.
if git ls-remote --exit-code --tags origin "refs/tags/v$BASE" >/dev/null 2>&1; then
echo "::error::Tag v$BASE already exists - bump .version before releasing." \
"Re-running this workflow as-is would overwrite the v$BASE release assets."
exit 1
fi
Build:
needs: Version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.Version.outputs.version }}
secrets: inherit
Release:
name: Publish Release
needs: [Version, Build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: rl-mobile-artifacts
path: ./dist/
- name: Prepare release assets
run: |
mv ./dist/app-release.apk ./dist/rl-manager.apk
cp patches/data.json ./dist/data.json
# Point each release's data.json at its own assets so historical releases stay self-contained.
sed -i "s|releases/download/latest/|releases/download/v${{ needs.Version.outputs.version }}/|g" ./dist/data.json
cd patches && zip -r ../dist/patches.zip . -x "data.json" && cd ..
tidal_src=$(find tidal-apk -maxdepth 1 \( -name "*.apk" -o -name "*.apkm" \) | head -1)
if [ -z "$tidal_src" ]; then
echo "::error::No TIDAL .apk or .apkm found in tidal-apk/"
exit 1
fi
if [[ "$tidal_src" == *.apkm ]]; then
echo "Merging splits from $tidal_src via APKEditor"
curl --fail --location --retry 3 --retry-delay 2 -sSo /tmp/APKEditor.jar \
https://github.com/REAndroid/APKEditor/releases/download/V1.4.9/APKEditor-1.4.9.jar
java -jar /tmp/APKEditor.jar m -i "$tidal_src" -o ./dist/tidal-stock.apk
echo "Merged tidal-stock.apk:"
ls -la ./dist/tidal-stock.apk
else
cp "$tidal_src" ./dist/tidal-stock.apk
fi
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.Version.outputs.version }}
name: v${{ needs.Version.outputs.version }}
prerelease: false
make_latest: "true"
files: ./dist/**