Files
openhuman/.github/workflows/version-bump.yml
T
Steven Enamakel 76ef0e7f3a 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.
2026-02-05 00:24:08 +05:30

91 lines
3.0 KiB
YAML

name: Version Bump
on:
push:
branches:
- main
permissions:
contents: write
jobs:
version-bump:
runs-on: ubuntu-latest
environment: Production
# Skip if this is a version bump commit to avoid infinite loop
if: "!contains(github.event.head_commit.message, 'chore: bump version') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Generate GitHub App token
id: app-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.XGITHUB_APP_ID }}
private_key: ${{ secrets.XGITHUB_APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
# Use GitHub App token for checkout and push operations
# This token has bypass permissions if the GitHub App is configured with them
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Configure Git
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Update remote URL to use GitHub App token for all git operations
git remote set-url origin https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
- name: Pull latest changes
run: |
# Ensure we're on main and pull latest changes to avoid push conflicts
git checkout main
git pull origin main --ff-only
- name: Bump version
id: version
run: |
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
export CURRENT_VERSION
echo "Current version: $CURRENT_VERSION"
# 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)
git push origin main
git push origin --tags