release.yml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. name: Check release blockers
  27. if: ${{ !github.event.inputs.force }}
  28. run: |
  29. if curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/issues?state=open&labels=release-blocker" | grep -Pzvo '\[[\s\n\r]*\]'; then
  30. echo "Open release-blocking issues found, cancelling release...";
  31. 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;
  32. fi
  33. - id: set-version
  34. name: Determine version
  35. run: |
  36. if [[ -n '${{ github.event.inputs.version }}' ]]; then
  37. echo 'RELEASE_VERSION=${{ github.event.inputs.version }}' >> $GITHUB_ENV;
  38. else
  39. DATE_PART=$(date +'%y.%-m')
  40. declare -i PATCH_VERSION=0
  41. while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do
  42. PATCH_VERSION+=1
  43. done
  44. echo "RELEASE_VERSION=${DATE_PART}.${PATCH_VERSION}" >> $GITHUB_ENV;
  45. fi
  46. - uses: actions/checkout@v2
  47. with:
  48. token: ${{ secrets.GH_SENTRY_BOT_PAT }}
  49. - id: set-git-user
  50. name: Set git user to getsentry-bot
  51. run: |
  52. git config user.name getsentry-bot
  53. git config user.email bot@getsentry.com
  54. - uses: getsentry/craft@master
  55. name: Craft Prepare
  56. if: ${{ !github.event.inputs.skip_prepare }}
  57. with:
  58. action: prepare
  59. version: ${{ env.RELEASE_VERSION }}
  60. env:
  61. DRY_RUN: ${{ github.event.inputs.dry_run }}
  62. ZEUS_API_TOKEN: ${{ secrets.ZEUS_API_TOKEN }}
  63. # Wait until the builds start. Craft should do this automatically
  64. # but it is broken now.
  65. - run: sleep 10
  66. - uses: getsentry/craft@master
  67. name: Craft Publish
  68. with:
  69. action: publish
  70. version: ${{ env.RELEASE_VERSION }}
  71. env:
  72. DRY_RUN: ${{ github.event.inputs.dry_run }}
  73. GITHUB_API_TOKEN: ${{ secrets.GH_SENTRY_BOT_PAT }}
  74. ZEUS_API_TOKEN: ${{ secrets.ZEUS_API_TOKEN }}
  75. TWINE_USERNAME: '__token__'
  76. TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
  77. DOCKER_USERNAME: 'sentrybuilder'
  78. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  79. - id: next-dev-version
  80. name: Set new version for development
  81. if: ${{ !github.event.inputs.dry_run }}
  82. run: |
  83. git checkout master
  84. ./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)
  85. git diff --quiet || git commit -anm 'meta: Bump new development version' && git pull --rebase && git push