Skip to content

feat: add a reader fold-state source (R816) #270

feat: add a reader fold-state source (R816)

feat: add a reader fold-state source (R816) #270

name: Auto Version Bump
on:
pull_request:
types: [closed]
branches:
- main
permissions:
contents: write
jobs:
bump-version:
name: Bump version
if: github.event.pull_request.merged == true
runs-on: ubuntu-24.04
steps:
- name: Clone repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
token: ${{ secrets.VERSION_BUMP_TOKEN }}
- name: Set up git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
# Extract current versions
CURRENT_VERSION_CODE=$(grep 'val appVersionCode = ' app/build.gradle.kts | sed 's/.*= //')
CURRENT_VERSION_NAME=$(grep 'versionName = "' app/build.gradle.kts | head -1 | sed 's/.*versionName = "\(.*\)"/\1/')
echo "Current versionCode: $CURRENT_VERSION_CODE"
echo "Current versionName: $CURRENT_VERSION_NAME"
# Parse version — scheme is {aniyomi_version}.{fork_build} e.g. 0.18.1.19
# prefix "0.18.1" tracks upstream Aniyomi 0.18.1; fork_build counts rayniyomi patches.
# The prefix is never auto-bumped — update it manually when pulling a new Aniyomi release.
UPSTREAM_PREFIX=$(echo "$CURRENT_VERSION_NAME" | sed 's/\.[^.]*$//')
FORK_BUILD=$(echo "$CURRENT_VERSION_NAME" | sed 's/.*\.//')
# Validate: both components must be present and FORK_BUILD must be a non-negative integer.
if [ -z "$UPSTREAM_PREFIX" ] || ! [[ "$FORK_BUILD" =~ ^[0-9]+$ ]]; then
echo "ERROR: Cannot parse versionName '$CURRENT_VERSION_NAME'."
echo " Expected format: X.Y.Z.N (e.g. 0.18.1.19)"
echo " Got UPSTREAM_PREFIX='$UPSTREAM_PREFIX' FORK_BUILD='$FORK_BUILD'"
echo "Fix versionName in app/build.gradle.kts before merging another PR."
exit 1
fi
# Increment versionCode
NEW_VERSION_CODE=$((CURRENT_VERSION_CODE + 1))
NEW_FORK_BUILD=$((FORK_BUILD + 1))
NEW_VERSION_NAME="${UPSTREAM_PREFIX}.${NEW_FORK_BUILD}"
BUMP_TYPE="fork build"
# Determine version bump type from PR title (informational only)
PR_TITLE="${{ github.event.pull_request.title }}"
echo "Bump type: $BUMP_TYPE"
echo "New versionCode: $NEW_VERSION_CODE"
echo "New versionName: $NEW_VERSION_NAME"
# Update build.gradle.kts
sed -i "s/val appVersionCode = $CURRENT_VERSION_CODE/val appVersionCode = $NEW_VERSION_CODE/" app/build.gradle.kts
sed -i "s/versionName = \"$CURRENT_VERSION_NAME\"/versionName = \"$NEW_VERSION_NAME\"/" app/build.gradle.kts
# Export for commit message
echo "version_code=$NEW_VERSION_CODE" >> $GITHUB_OUTPUT
echo "version_name=$NEW_VERSION_NAME" >> $GITHUB_OUTPUT
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
echo "pr_title=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
- name: Commit and push
run: |
git add app/build.gradle.kts
git commit -m "chore: bump version to ${{ steps.bump.outputs.version_name }} (build ${{ steps.bump.outputs.version_code }})
Version bump type: ${{ steps.bump.outputs.bump_type }}
Auto-generated after merging PR #${{ steps.bump.outputs.pr_number }}: ${{ steps.bump.outputs.pr_title }}"
git push origin main