bump-version.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  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. if git diff --exit-code; then
  47. exit 0
  48. fi
  49. git \
  50. -c user.name=getsentry-bot \
  51. -c user.email='10587625+getsentry-bot@users.noreply.github.com' \
  52. commit \
  53. --all \
  54. --message "ref: bump $PACKAGE to $VERSION" \
  55. --message "Co-Authored-By: $SENDER <$SENDER_ID+$SENDER@users.noreply.github.com>"
  56. git push origin HEAD --quiet
  57. gh pr create --fill ${{ inputs.pr_options }}
  58. env:
  59. GH_TOKEN: ${{ secrets.BUMP_SENTRY_TOKEN }}
  60. PACKAGE: ${{ inputs.package }}
  61. VERSION: ${{ inputs.version }}
  62. SENDER: ${{ github.event.sender.login }}
  63. SENDER_ID: ${{ github.event.sender.id }}