Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
Expand All @@ -16,11 +17,26 @@ concurrency:
jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'JabRef/html-to-node'
# Fork PRs get no secrets, so they can never publish - don't even start the job for them
if: github.repository == 'JabRef/html-to-node' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
steps:
- uses: actions/checkout@v7
with:
show-progress: 'false'
# Publish the branch as-is, not GitHub's main-merged ref, and keep enough
# history for the is-up-to-date check below
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
- name: Skip if branch is behind main
id: uptodate
# A stale branch would publish a snapshot missing commits that are already on
# main, silently downgrading the artifact for everyone consuming it
run: |
git fetch --no-tags origin main
if [ "${{ github.event_name }}" = "pull_request" ] && ! git merge-base --is-ancestor FETCH_HEAD HEAD; then
echo "Branch is behind main - rebase/merge main before a snapshot is published."
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup JDK
uses: actions/setup-java@v5
with:
Expand All @@ -45,11 +61,14 @@ jobs:
mavenCentralPassword=${{ secrets.KOPPOR_MAVENCENTRALPASSWORD }}
EOF
- name: Publish snapshot
if: steps.uptodate.outputs.skip != 'true'
# Release versions are published by release.yml on tag push; this workflow only
# handles the rolling snapshot
run: |
if ! grep -q 'version = ".*-SNAPSHOT"' build.gradle.kts; then
if ! grep -q '^version = .*SNAPSHOT' build.gradle.kts; then
echo "Version is not a SNAPSHOT - skipping (releases go through release.yml)."
exit 0
fi
./gradlew publishAllPublicationsToMavenCentralRepository
./gradlew ${PR_NUMBER:+-PversionSuffix=PR$PR_NUMBER} publishAllPublicationsToMavenCentralRepository
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
EOF
- name: Guard against SNAPSHOT releases
run: |
if grep -q 'version = ".*-SNAPSHOT"' build.gradle.kts; then
if grep -q '^version = .*SNAPSHOT' build.gradle.kts; then
echo "Tagged commit still has a SNAPSHOT version - refusing to release."
exit 1
fi
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ plugins {
}

group = "org.jabref"
version = "0.2.0-SNAPSHOT"
// -PversionSuffix=PR17 turns 0.2.0-SNAPSHOT into 0.2.0-PR17-SNAPSHOT, so a pull request
// snapshot is identifiable and does not clobber the one built from main
version = "0.2.0" + (findProperty("versionSuffix")?.let { "-$it" } ?: "") + "-SNAPSHOT"

repositories {
mavenCentral()
Expand Down