release.yml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: Version to release
  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. # Wait until the builds start. Craft should do this automatically
  63. # but it is broken now.
  64. # TODO: Remove this once getsentry/craft#111 is fixed
  65. - run: sleep 10
  66. - uses: getsentry/craft@master
  67. with:
  68. action: publish
  69. version: ${{ env.RELEASE_VERSION }}
  70. env:
  71. DRY_RUN: ${{ github.event.inputs.dry_run }}
  72. GITHUB_API_TOKEN: ${{ secrets.GH_SENTRY_BOT_PAT }}
  73. ZEUS_API_TOKEN: ${{ secrets.ZEUS_API_TOKEN }}
  74. TWINE_USERNAME: '__token__'
  75. TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
  76. DOCKER_USERNAME: 'sentrybuilder'
  77. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  78. - id: next-dev-version
  79. if: ${{ !github.event.inputs.dry_run }}
  80. run: |
  81. ./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)
  82. git diff --quiet || git commit -anm 'meta: Bump new development version' && git push