Version Bump and Release #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Version Bump and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - custom | |
| default: 'patch' | |
| custom_version: | |
| description: 'Custom version (only used if version_type is "custom")' | |
| required: false | |
| type: string | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.VERCEL_RELEASE_BOT_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "vercel-release-bot" | |
| git config --global user.email "infra+release@vercel.com" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Bump version | |
| id: version_bump | |
| run: | | |
| if [ "${{ inputs.version_type }}" = "custom" ]; then | |
| if [ -z "${{ inputs.custom_version }}" ]; then | |
| echo "Error: Custom version is required when version_type is 'custom'" | |
| exit 1 | |
| fi | |
| pnpm version ${{ inputs.custom_version }} --no-git-tag-version | |
| NEW_VERSION="${{ inputs.custom_version }}" | |
| else | |
| pnpm version ${{ inputs.version_type }} --no-git-tag-version | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| fi | |
| echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | |
| echo "New version: ${NEW_VERSION}" | |
| - name: Commit and push changes | |
| run: | | |
| git add package.json | |
| git commit -m "chore: bump version to ${{ steps.version_bump.outputs.new_version }}" | |
| git tag -a "v${{ steps.version_bump.outputs.new_version }}" -m "Release v${{ steps.version_bump.outputs.new_version }}" | |
| git push origin ${{ github.ref_name }} | |
| git push origin "v${{ steps.version_bump.outputs.new_version }}" |