Kode-cli/.github/workflows/version-bump.yml
2025-08-10 19:57:17 +08:00

67 lines
1.9 KiB
YAML

name: Version Bump
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version type (patch, minor, major)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Configure Git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Bump version
id: bump_version
run: |
# Get current version
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Bump version using npm version
npm version ${{ github.event.inputs.version_type }} --no-git-tag-version
# Get new version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Commit and push changes
run: |
git add package.json
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}"
git push origin HEAD:main
- name: Create and push tag
run: |
git tag -a v${{ steps.bump_version.outputs.new_version }} -m "Release v${{ steps.bump_version.outputs.new_version }}"
git push origin --tags