version-bump.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Version Bump
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. bump:
  6. description: 'Type of version bump'
  7. required: true
  8. type: choice
  9. options:
  10. - patch
  11. - minor
  12. - major
  13. permissions:
  14. contents: write
  15. pull-requests: write
  16. jobs:
  17. bump-version:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - uses: actions/checkout@v4
  21. with:
  22. token: ${{ secrets.GITHUB_TOKEN }}
  23. - name: Use Node.js 20.x
  24. uses: actions/setup-node@v4
  25. with:
  26. node-version: '20.x'
  27. cache: 'npm'
  28. - name: Configure Git
  29. run: |
  30. git config --global user.name 'github-actions[bot]'
  31. git config --global user.email 'github-actions[bot]@users.noreply.github.com'
  32. - name: Install dependencies
  33. run: npm ci
  34. - name: Bump version
  35. run: |
  36. npm version ${{ github.event.inputs.bump }} -m "chore: bump version to %s"
  37. echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
  38. - name: Push changes
  39. run: |
  40. git push origin HEAD:refs/heads/version-bump-${{ env.NEW_VERSION }}
  41. git push origin --tags
  42. - name: Create Pull Request
  43. uses: peter-evans/create-pull-request@v6
  44. with:
  45. token: ${{ secrets.GITHUB_TOKEN }}
  46. branch: version-bump-${{ env.NEW_VERSION }}
  47. title: 'chore: bump version to ${{ env.NEW_VERSION }}'
  48. body: |
  49. This PR bumps the version to ${{ env.NEW_VERSION }}.
  50. After merging, a new release will be created automatically.
  51. labels: |
  52. version-bump
  53. automated