Skip to content

Merge branch 'main' of https://github.com/alp-kurt/max-ad-implementat… #16

Merge branch 'main' of https://github.com/alp-kurt/max-ad-implementat…

Merge branch 'main' of https://github.com/alp-kurt/max-ad-implementat… #16

name: Update versionCode in Release PR
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: ["main"]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
set-versioncode:
# Only run on release-please PRs (they carry the "autorelease: pending" label)
if: ${{ contains(github.event.pull_request.labels.*.name, 'autorelease: pending') }}

Check failure on line 16 in .github/workflows/release-pr-versioncode.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release-pr-versioncode.yml

Invalid workflow file

You have an error in your yaml syntax on line 16
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Sanity check file presence
run: |
ls -la Assets || true
if [ ! -f Assets/version.txt ]; then
echo "Assets/version.txt not found on PR branch."
echo "Tip: ensure release-please updates this path (extra-files) and the file exists in main."
fi
- name: Compute versionCode from semver in manifest
shell: bash
run: |
# Read the next version from release-please manifest in the PR
VER=$(jq -r '."."' .github/.release-please-manifest.json)
echo "Next version is: $VER"
# Extract MAJOR.MINOR.PATCH (ignore prerelease/build metadata if present)
if [[ "$VER" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
else
echo "Could not parse semver from: $VER"
exit 1
fi
# Monotonic integer strategy for Google Play:
# versionCode = MAJOR*10000 + MINOR*100 + PATCH (e.g., 2.3.4 -> 20304)
CODE=$((MAJOR*10000 + MINOR*100 + PATCH))
echo "Computed versionCode: $CODE"
# Write into Assets/ (not repo root)
echo $CODE > Assets/versionCode.txt
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Assets/versionCode.txt
git commit -m "chore(android): set versionCode $CODE for $VER" || echo "No changes to commit"
git push