From 8e35d543bd141aadd5f183f9cb88ff6372690e39 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 9 Oct 2025 12:51:28 +0200 Subject: [PATCH] nix: adjust release tool to new versioning scheme Resolves #4166 --- .github/workflows/ci.yaml | 2 +- nix/tools/release.nix | 37 +++++++++++++++---------------------- src/PostgREST/Version.hs | 10 +++++----- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1490123e..33bd94dfb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,7 +57,7 @@ jobs: run: | cabal_version="$(grep -oP '^version:\s*\K.*' postgrest.cabal)" - if [[ "$cabal_version" == *.*.* ]]; then + if [[ "$cabal_version" == *.*.*.* ]]; then git fetch --tags if [ -z "$(git tag --list "v$cabal_version")" ]; then diff --git a/nix/tools/release.nix b/nix/tools/release.nix index ec52f0f66..3f6ac74dc 100644 --- a/nix/tools/release.nix +++ b/nix/tools/release.nix @@ -20,27 +20,24 @@ let git diff --exit-code HEAD postgrest.cabal > /dev/null trap "" ERR + # TODO: Support C+D bumps when implementing hackage releases bump () { current_version="$(grep -oP '^version:\s*\K.*' postgrest.cabal)" # shellcheck disable=SC2034 - IFS=. read -r major minor patch <<< "$current_version" + IFS=. read -r A B C D <<< "$current_version" echo "Current version is $current_version" case "$1" in - major) - new_version="$((major+1)).0.0" - new_docs_version="$((major+1)).0" + A) + new_version="$((A+1)).0" + new_docs_version="$((A+1))" ;; - minor) - new_version="$major.$((minor+1)).0" - new_docs_version="$major.$((minor+1))" - ;; - patch) - new_version="$major.$minor.$((patch+1))" - new_docs_version="$major.$minor" + B) + new_version="$A.$((B+1))" + new_docs_version="$A" ;; devel) - new_version="$major.$((minor+1))" + new_version="$((A+1))" new_docs_version="devel" ;; esac @@ -55,13 +52,9 @@ let today_date_for_changelog="$(date '+%Y-%m-%d')" if [[ "$current_branch" == "main" ]]; then - if [[ "$_arg_major" == "on" ]]; then - bump major - else - bump minor - fi + bump A else - bump patch + bump B fi echo "Updating CHANGELOG.md ..." @@ -75,10 +68,10 @@ let bump devel # The order of operations is important here: - # - bump devel is run and $major is upated to the new version - # - the branch is created with the new major, but the commit before the devel bump + # - bump devel is run and $A is upated to the new version + # - the branch is created with the new A, but the commit before the devel bump # - the devel bump is committed - git branch -f "v$major" + git branch "v$A" echo "Committing (devel bump)..." git commit -m "bump version to $new_version" > /dev/null @@ -90,7 +83,7 @@ let if [[ "$current_branch" == "main" ]]; then push1="git push $remote $current_branch" - push2="git push $remote v$major --force" + push2="git push $remote v$A" else push1="git push $remote $current_branch" push2="" diff --git a/src/PostgREST/Version.hs b/src/PostgREST/Version.hs index 54102994a..c1a9cf549 100644 --- a/src/PostgREST/Version.hs +++ b/src/PostgREST/Version.hs @@ -11,11 +11,11 @@ import Protolude version :: [Text] version = T.splitOn "." VERSION_postgrest --- | User friendly version number such as '1.1.1'. --- Pre-release versions are tagged as such, e.g., '1.1 (pre-release)'. +-- | User friendly version number such as '14.0'. +-- Pre-release versions are tagged as such, e.g., '15 (pre-release)'. prettyVersion :: ByteString prettyVersion = - VERSION_postgrest <> preRelease + (encodeUtf8 . T.intercalate "." $ take 2 version) <> preRelease where preRelease = if isPreRelease then " (pre-release)" else mempty @@ -29,7 +29,7 @@ docsVersion | otherwise = "v" <> T.intercalate "." (take 1 version) --- | Versions with two components (e.g., '1.1') are treated as pre-releases. +-- | Versions with one components (e.g., '15') are treated as pre-releases. isPreRelease :: Bool isPreRelease = - length version == 2 + length version == 1