bump.yaml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. name: Bump version
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. bump_rule:
  6. type: choice
  7. description: How to bump the project's version (see https://python-poetry.org/docs/cli/#version)
  8. options:
  9. - patch
  10. - minor
  11. - major
  12. - prepatch
  13. - preminor
  14. - premajor
  15. - prerelease
  16. required: true
  17. jobs:
  18. bump_version:
  19. name: "Bump version and create changelog"
  20. if: "!startsWith(github.event.head_commit.message, 'bump:')"
  21. runs-on: ubuntu-latest
  22. env:
  23. CI_COMMIT_EMAIL: "ci-runner@unfccc-ghg-data.invalid"
  24. steps:
  25. - name: Check out repository
  26. uses: actions/checkout@v3
  27. with:
  28. fetch-depth: 0
  29. token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
  30. # towncrier imports the package as part of building so we have to
  31. # install the pacakage (to keep things slim, we only install the main
  32. # dependencies, which also means that we get a test that we can import
  33. # the package with only the compulsory dependencies installed for free)
  34. - uses: ./.github/actions/setup
  35. with:
  36. python-version: "3.11"
  37. venv-id: "bump"
  38. poetry-dependency-install-flags: "--only main"
  39. - name: Install towncrier
  40. run: |
  41. poetry run pip install towncrier
  42. - name: Create bump and changelog
  43. run: |
  44. git config --global user.name "$GITHUB_ACTOR"
  45. git config --global user.email "$CI_COMMIT_EMAIL"
  46. # Bump
  47. BASE_VERSION=`poetry version -s`
  48. NEW_VERSION=`poetry version -s ${{ github.event.inputs.bump_rule }}`
  49. echo "Bumping version $BASE_VERSION > $NEW_VERSION"
  50. poetry run towncrier build --yes --version v$NEW_VERSION
  51. git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION"
  52. git tag v$NEW_VERSION
  53. # Bump to alpha (so that future commits do not have the same
  54. # version as the tagged commit)
  55. BASE_VERSION=`poetry version -s`
  56. NEW_VERSION=`poetry version -s prerelease`
  57. echo "Bumping version $BASE_VERSION > $NEW_VERSION"
  58. git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
  59. git push && git push --tags