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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
22 changes: 22 additions & 0 deletions scripts/check-version-bump
Original file line number Diff line number Diff line change
@@ -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"
Loading