Skip to content

CI: fix Play Console edit auth scope and silent versionCode fallback - #685

Merged
Mansimran Singh (Mansimran-Singh) merged 1 commit into
mainfrom
feature/626/fix-version-code-edit-auth
Aug 19, 2026
Merged

CI: fix Play Console edit auth scope and silent versionCode fallback#685
Mansimran Singh (Mansimran-Singh) merged 1 commit into
mainfrom
feature/626/fix-version-code-edit-auth

Conversation

@Mansimran-Singh

Copy link
Copy Markdown
Collaborator

Summary

  • The real dry run from CI: build App Bundle for Play Store uploads instead of APK #684 got past the APK/bundle mismatch but failed with Version code 31 has already been used. The actual cause, visible in the run log, was get-next-version-code.sh failing to create a Play Console edit (Failed to create a Play Console edit for com.willowtree.vocable) and silently falling back to versionCode = 1 + 30 = 31 via build.gradle.kts's legacy + 30 offset — landing exactly on an already-used code by coincidence.
  • Root cause: the google-github-actions/auth step in both workflows never set access_token_scopes, defaulting to the generic cloud-platform scope, which the Android Publisher API's edits.insert call rejects. It needs the androidpublisher scope specifically. (The later r0adkll/upload-google-play step works today because it authenticates independently from the raw service account JSON with the correct scope baked in — that's why this was masked until the version-code step ran.)
  • Also fixed the step that swallowed the script's failure: echo "value=$(script)" >> "$GITHUB_OUTPUT" always reports success because echo itself succeeds even when the substituted command fails. Now assigns to a variable first so a real failure aborts the step loudly instead of silently defaulting to versionCode 1.

Ticket

Related to #626

Type of Change

  • New feature
  • Bug fix
  • Refactor
  • Tests
  • CI/CD
  • Documentation

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

CI workflow config only, no unit-testable logic. Verified by reading the actual failed run's log (gh run view <id> --log) to confirm the edit-creation failure and the empty VERSION_CODE env var reaching the build step. The real validation happens on the next merge to main, which triggers pre-release-upload.yml automatically.

Checklist

  • Tests pass locally (./gradlew testDebug)
  • No API keys or secrets in code
  • CLAUDE.md updated (if new pattern introduced)

The real 2026-08-19 dry run (PR #684, pre-release-upload.yml) got past
the APK/bundle mismatch but failed on "Version code 31 has already
been used." The log showed the actual cause: get-next-version-code.sh
printed "Failed to create a Play Console edit for com.willowtree.vocable"
and produced no output, but the calling step still reported success —
`echo "value=$(script)" >> "$GITHUB_OUTPUT"` swallows the inner
command's exit code because echo itself always succeeds. Downstream,
build.gradle.kts's `System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1`
fell back to 1, and its legacy `+ 30` offset landed on exactly the
already-published version code (31) — a coincidence that made the
failure look like a version-code bug rather than an auth bug.

Root cause of the edit-creation failure: the `google-github-actions/auth`
step never set `access_token_scopes`, so it defaults to the generic
`cloud-platform` scope, which the Android Publisher API's edits.insert
call rejects — it needs the `androidpublisher` scope specifically. The
later r0adkll/upload-google-play step works today because it
authenticates independently from the raw service account JSON with the
correct scope built in, masking this from the earlier failure.

Fixes:
- Set access_token_scopes to https://www.googleapis.com/auth/androidpublisher
  on the auth step in both workflows.
- Assign the script's output to a variable before writing it to
  GITHUB_OUTPUT, so a real failure aborts the step instead of silently
  falling back to versionCode 1.

Related to #626.
@Mansimran-Singh
Mansimran Singh (Mansimran-Singh) merged commit 0718945 into main Aug 19, 2026
4 checks passed
@Mansimran-Singh
Mansimran Singh (Mansimran-Singh) deleted the feature/626/fix-version-code-edit-auth branch August 19, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant