Skip to content

Publish snapshot for same-repo pull requests#17

Merged
koppor merged 2 commits into
mainfrom
snapshot-on-pr
Jul 19, 2026
Merged

Publish snapshot for same-repo pull requests#17
koppor merged 2 commits into
mainfrom
snapshot-on-pr

Conversation

@koppor

@koppor koppor commented Jul 19, 2026

Copy link
Copy Markdown
Member

🤖 Publishes the rolling -SNAPSHOT from pull request branches, so JabRef can test a library change before it lands on main.

Each PR gets its own version: -PversionSuffix=PR17 makes 0.2.0-SNAPSHOT into 0.2.0-PR17-SNAPSHOT, so PR snapshots are identifiable and never clobber the one built from main (or each other). No GitVersion or similar plugin needed - it is one expression in build.gradle.kts.

Two guards:

  • Fork PRs are skipped. They get no secrets, so publishing could never work anyway - the job condition compares pull_request.head.repo.full_name against the repository.
  • Branches behind main are skipped. Publishing a stale branch would push a snapshot missing commits already on main. The check is git merge-base --is-ancestor against freshly fetched origin/main.

The checkout now uses the PR head SHA rather than GitHub's main-merged ref, so what is published is exactly the branch.

The -SNAPSHOT grep in publish.yml and release.yml was loosened to ^version = .*SNAPSHOT since the version line is now an expression.

How to test

  • ./gradlew -q properties -PversionSuffix=PR17 | grep '^version:'0.2.0-PR17-SNAPSHOT; without the flag → 0.2.0-SNAPSHOT.
  • Open a PR from a branch in this repo that is up to date with main → the publish job runs and uploads 0.2.0-PR<n>-SNAPSHOT.
  • Let main move ahead, re-run → the job runs but the "Publish snapshot" step is skipped with the "behind main" message.
  • Open a PR from a fork → no publish job at all.

🤖 Generated with Claude Code

Fork PRs cannot publish (no secrets), and branches behind main would push a
snapshot missing commits already on main, so both are skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01159RbWmMUr4KQrDuxGBPx9
@koppor
koppor marked this pull request as draft July 19, 2026 20:05
-PversionSuffix=PR17 yields 0.2.0-PR17-SNAPSHOT, so a pull request snapshot is
identifiable and does not clobber the one built from main.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01159RbWmMUr4KQrDuxGBPx9
@koppor
koppor marked this pull request as ready for review July 19, 2026 20:36
@koppor
koppor requested a review from Siedlerchr July 19, 2026 20:36
@koppor
koppor merged commit 34a16f9 into main Jul 19, 2026
4 checks passed
@koppor
koppor deleted the snapshot-on-pr branch July 19, 2026 20:36
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