bump-version.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. on:
  2. workflow_dispatch:
  3. inputs:
  4. package:
  5. required: true
  6. type: string
  7. description: package name such as `sentry-arroyo`
  8. version:
  9. required: true
  10. type: string
  11. description: desired version such as `1.2.3`, or `latest` to pull the latest version from PyPI
  12. pr_options:
  13. type: string
  14. default: ''
  15. description: additional options for gh pr create, such as for asking for specific reviewers
  16. # for use in other (cron/scheduled) workflows to bump specific
  17. # company-internal dependencies on a more aggressive schedule
  18. workflow_call:
  19. inputs:
  20. package:
  21. required: true
  22. type: string
  23. version:
  24. required: true
  25. type: string
  26. pr_options:
  27. type: string
  28. default: ''
  29. # disable all permissions -- we use the PAT's permissions instead
  30. permissions: {}
  31. jobs:
  32. bump-version:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  36. with:
  37. token: ${{ secrets.BUMP_SENTRY_TOKEN }}
  38. - run: |
  39. set -euxo pipefail
  40. if [ "$VERSION" = latest ]; then
  41. VERSION="$(curl -sL https://pypi.org/pypi/$PACKAGE/json | jq -r .info.version)"
  42. fi
  43. git checkout -b "bot/bump-version/$PACKAGE/$VERSION"
  44. re="$(sed 's/[_-]/[_-]/g' <<< "$PACKAGE")"
  45. sed -i "s/^$re==.*/$PACKAGE==$VERSION/g" -- requirements*.txt
  46. sed -i "s/^$re>=.*/$PACKAGE>=$VERSION/g" -- requirements*.txt
  47. if git diff --exit-code; then
  48. exit 0
  49. fi
  50. git \
  51. -c user.name=getsentry-bot \
  52. -c user.email='10587625+getsentry-bot@users.noreply.github.com' \
  53. commit \
  54. --all \
  55. --message "ref: bump $PACKAGE to $VERSION" \
  56. --message "Co-Authored-By: $SENDER <$SENDER_ID+$SENDER@users.noreply.github.com>"
  57. git push origin HEAD --quiet
  58. gh pr create --fill ${{ inputs.pr_options }}
  59. env:
  60. GH_TOKEN: ${{ secrets.BUMP_SENTRY_TOKEN }}
  61. PACKAGE: ${{ inputs.package }}
  62. VERSION: ${{ inputs.version }}
  63. SENDER: ${{ github.event.sender.login }}
  64. SENDER_ID: ${{ github.event.sender.id }}