release.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: Version to release (optional)
  7. required: false
  8. skip_prepare:
  9. description: Skip preparation step (assume a release branch is ready)
  10. required: false
  11. default: false
  12. dry_run:
  13. description: Do not actually cut the release
  14. required: false
  15. default: false
  16. schedule:
  17. # We want the release to be at 9-10am Pacific Time
  18. # We also want it to be 1 hour before the on-prem release
  19. - cron: '0 17 15 * *'
  20. jobs:
  21. release:
  22. runs-on: ubuntu-latest
  23. name: 'Release a new version'
  24. steps:
  25. - id: killswitch
  26. if: ${{ !github.event.inputs.force }}
  27. run: |
  28. if curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/issues?state=open&labels=release-blocker" | grep -Pzvo '\[[\s\n\r]*\]'; then
  29. echo "Open release-blocking issues found, cancelling release...";
  30. curl -sf -X POST -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}/cancel;
  31. fi
  32. - id: set-version
  33. run: |
  34. if [[ -n '${{ github.event.inputs.version }}' ]]; then
  35. echo '::set-env name=RELEASE_VERSION::${{ github.event.inputs.version }}';
  36. else
  37. DATE_PART=$(date +'%y.%-m')
  38. declare -i PATCH_VERSION=0
  39. while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do
  40. PATCH_VERSION+=1
  41. done
  42. echo "::set-env name=RELEASE_VERSION::${DATE_PART}.${PATCH_VERSION}"
  43. fi
  44. - uses: actions/checkout@v2
  45. with:
  46. token: ${{ secrets.GH_SENTRY_BOT_PAT }}
  47. - id: set-git-user
  48. run: |
  49. git config user.name getsentry-bot
  50. git config user.email bot@getsentry.com
  51. - uses: getsentry/craft@master
  52. if: ${{ !github.event.inputs.skip_prepare }}
  53. with:
  54. action: prepare
  55. version: ${{ env.RELEASE_VERSION }}
  56. env:
  57. DRY_RUN: ${{ github.event.inputs.dry_run }}
  58. GIT_COMMITTER_NAME: getsentry-bot
  59. GIT_AUTHOR_NAME: getsentry-bot
  60. EMAIL: bot@getsentry.com
  61. ZEUS_API_TOKEN: ${{ secrets.ZEUS_API_TOKEN }}
  62. - uses: getsentry/craft@master
  63. with:
  64. action: publish
  65. version: ${{ env.RELEASE_VERSION }}
  66. env:
  67. DRY_RUN: ${{ github.event.inputs.dry_run }}
  68. GITHUB_API_TOKEN: ${{ secrets.GH_SENTRY_BOT_PAT }}
  69. ZEUS_API_TOKEN: ${{ secrets.ZEUS_API_TOKEN }}
  70. TWINE_USERNAME: '__token__'
  71. TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
  72. DOCKER_USERNAME: 'sentrybuilder'
  73. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  74. - id: next-dev-version
  75. if: ${{ !github.event.inputs.dry_run }}
  76. run: |
  77. ./scripts/bump-version.sh '' $(date -d "$(echo $RELEASE_VERSION | sed -e 's/^\([0-9]\{2\}\)\.\([0-9]\{1,2\}\)\.[0-9]\+$/20\1-\2-1/') 1 month" +%y.%-m.0.dev0)
  78. git diff --quiet || git commit -anm 'meta: Bump new development version' && git push