Move plugin version into .env, fix version-bump workflow to only touch it
The old workflow grepped CMakeLists.txt for the first "VERSION X.Y" match, which was cmake_minimum_required's own version rather than the project's, mangling it to 3.27.0.0 on the first real bump. PLUGIN_VERSION in .env is now the single source of truth for both CMakeLists.txt and flake.nix, and the workflow's bump/commit steps only ever touch that one file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,29 +50,26 @@ jobs:
|
||||
echo "::error::merged PR into develop has no bump/major, bump/minor, bump/patch, or bump/skip label"
|
||||
exit 1
|
||||
|
||||
- name: Bump CMakeLists.txt and flake.nix
|
||||
- name: Bump PLUGIN_VERSION in .env
|
||||
if: steps.level.outputs.level != 'skip'
|
||||
env:
|
||||
LEVEL: ${{ steps.level.outputs.level }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
CURRENT=$(grep -oP '(?<=VERSION )[0-9]+(\.[0-9]+){1,2}' CMakeLists.txt | head -1)
|
||||
|
||||
# Pad to 3 components so a pre-existing 2-component version (e.g.
|
||||
# "0.1") still splits into MAJOR/MINOR/PATCH correctly.
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "${CURRENT}.0.0"
|
||||
CURRENT=$(sed -n 's/^PLUGIN_VERSION=//p' .env)
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
|
||||
|
||||
case "$LEVEL" in
|
||||
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH + 1)) ;;
|
||||
*) echo "::error::unknown bump level '$LEVEL'"; exit 1 ;;
|
||||
esac
|
||||
|
||||
NEW="$MAJOR.$MINOR.$PATCH"
|
||||
|
||||
sed -i "s/VERSION ${CURRENT}/VERSION ${NEW}/" CMakeLists.txt
|
||||
sed -i "s/version = \"${CURRENT}\"/version = \"${NEW}\"/" flake.nix
|
||||
sed -i "s/^PLUGIN_VERSION=.*/PLUGIN_VERSION=${NEW}/" .env
|
||||
|
||||
echo "CURRENT_VERSION=${CURRENT}" >> "$GITHUB_ENV"
|
||||
echo "NEW_VERSION=${NEW}" >> "$GITHUB_ENV"
|
||||
@@ -87,6 +84,6 @@ jobs:
|
||||
fi
|
||||
git config user.name "gitea-actions"
|
||||
git config user.email "actions@noreply.localhost"
|
||||
git add CMakeLists.txt flake.nix
|
||||
git commit -m "Bump version to ${NEW_VERSION}"
|
||||
git add .env
|
||||
git commit -m "Bump PLUGIN_VERSION to ${NEW_VERSION}"
|
||||
git push origin HEAD:develop
|
||||
|
||||
Reference in New Issue
Block a user