chore: automate version bumping in CI workflow

- Enhanced the version-bump.yml workflow to automatically update the version in package.json and Cargo.toml files.
- Implemented logic to compute the new minor version and create a single commit and tag for both npm and Cargo.
- Ensured the workflow prevents triggering itself by including [skip ci] in the commit message.
This commit is contained in:
Steven Enamakel
2026-02-05 00:24:08 +05:30
parent 6fa6b377fe
commit 76ef0e7f3a
+23 -4
View File
@@ -54,16 +54,35 @@ jobs:
- name: Bump version
id: version
run: |
# Get current version
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
export CURRENT_VERSION
echo "Current version: $CURRENT_VERSION"
# Bump minor version (creates commit and tag)
# The commit message includes [skip ci] to prevent triggering this workflow again
NEW_VERSION=$(npm version minor -m "chore: bump version to %s [skip ci]" | sed 's/v//')
# Compute new version (minor bump: x.y.z -> x.(y+1).0)
NEW_VERSION=$(node -e "
const v = process.env.CURRENT_VERSION.split('.').map(Number);
console.log([v[0], (v[1] || 0) + 1, 0].join('.'));
")
export NEW_VERSION
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
# Update package.json
node -e "
const p = require('./package.json');
p.version = process.env.NEW_VERSION;
require('fs').writeFileSync('package.json', JSON.stringify(p, null, 2) + '\n');
"
# Update Cargo.toml to match
sed -i 's/^version = .*/version = "'"$NEW_VERSION"'"/' src-tauri/Cargo.toml
# Single commit and tag for both npm and Cargo
git add package.json src-tauri/Cargo.toml
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
git tag "v$NEW_VERSION"
- name: Push changes
run: |
# Push to main and tags using GitHub App token (remote URL already configured)