From e65f9e12610c06c01c23691dc4fb97ddcc11bf21 Mon Sep 17 00:00:00 2001 From: Wes John-Alder Date: Fri, 16 Oct 2026 15:13:32 -0400 Subject: [PATCH] Require a version bump on every PR GitHub Packages rejects a second publish of one version, so the publish job on main fails whenever a PR merges without bumping build.sbt. A new CI job runs scripts/check-version-bump on each PR and fails when the version matches main. Bump to 0.0.16 so the next publish succeeds. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/ci.yml | 11 +++++++++++ README.md | 3 ++- build.sbt | 2 +- scripts/check-version-bump | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 scripts/check-version-bump diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9be7899..d034dd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,17 @@ env: SBT_OPTS: "-Xmx4G -XX:+UseG1GC" jobs: + version: + name: Check the version bump + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Fail unless build.sbt bumps the version + run: ./scripts/check-version-bump + native: name: Native library (${{ matrix.platform }}) runs-on: ${{ matrix.runner }} diff --git a/README.md b/README.md index 73a5ab7..afa2316 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,8 @@ On a push to `main` that job publishes the jar to GitHub Packages. That jar has no classifier. At runtime sbt-jni reads `uname -sm` and loads the library from the directory with that name. -GitHub Packages rejects a second publish of the same version, so bump `ThisBuild / version` in `build.sbt` for every PR that changes the library. +GitHub Packages rejects a second publish of the same version, so bump `ThisBuild / version` in `build.sbt` in every PR. +A CI job on each PR runs `scripts/check-version-bump` and fails when the version matches main. ### Troubleshooting diff --git a/build.sbt b/build.sbt index b8cca47..7b55363 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import Dependencies._ ThisBuild / scalaVersion := "2.13.15" -ThisBuild / version := "0.0.15" +ThisBuild / version := "0.0.16" ThisBuild / versionScheme := Some("early-semver") ThisBuild / organization := "io.citrine" ThisBuild / organizationName := "Citrine Informatics" diff --git a/scripts/check-version-bump b/scripts/check-version-bump new file mode 100755 index 0000000..994176f --- /dev/null +++ b/scripts/check-version-bump @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Fail unless build.sbt sets a version that differs from the one on main. +# GitHub Packages rejects a second publish of the same version, so every merge must bump it. +set -euo pipefail + +cd "$(dirname "$0")/.." + +git fetch --quiet origin main:refs/remotes/origin_main + +extract_version() { + grep -E '^ThisBuild / version +:=' | sed -nE 's/.*"([^"]+)".*/\1/p' +} + +head_version=$(extract_version < build.sbt) +main_version=$(git cat-file blob origin_main:build.sbt | extract_version) + +if [[ "$head_version" == "$main_version" ]]; then + echo "build.sbt still sets version $main_version, the version on main. Bump it before merging." >&2 + exit 1 +fi + +echo "Version bumps from $main_version to $head_version"