From 78d5bdbaffbfa7b10735eac335147962235db5b7 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Thu, 9 Feb 2023 13:09:53 +0100 Subject: [PATCH] ci: Streamline Gitflow release process --- .github/workflows/auto-release.yml | 38 ++++++++++++++ .github/workflows/build.yml | 3 +- .github/workflows/gitflow-sync-master.yml | 62 ----------------------- docs/publishing-a-release.md | 16 +++--- 4 files changed, 48 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/auto-release.yml delete mode 100644 .github/workflows/gitflow-sync-master.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 000000000000..21556dc2e5a1 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,38 @@ +name: Gitflow - Auto prepare release +on: + pull_request: + types: + - closed + branches: + - master + +# This workflow tirggers a release when merging a branch with the pattern `prepare-release/VERSION` into master. +jobs: + release: + runs-on: ubuntu-20.04 + name: 'Prepare a new version' + + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_RELEASE_PAT }} + fetch-depth: 0 + + # https://github.com/actions-ecosystem/action-regex-match + - uses: actions-ecosystem/action-regex-match@v2 + id: version + with: + # Parse version from head branch + text: ${{ github.head_ref }} + # match: refs/heads/preprare-release/xx.xx.xx + regex: '^refs\/heads\/preprare-release\/(\d+\.\d+\.\d+)$' + + - name: Prepare release + uses: getsentry/action-prepare-release@v1 + if: github.event.pull_request.merged == true && steps.version.outputs.match != '' + env: + GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }} + with: + version: ${{ steps.version.outputs.match != '' }} + force: false + merge_target: master diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90a9657b0938..d9fb4f556826 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,7 +137,8 @@ jobs: # Note: These next three have to be checked as strings ('true'/'false')! is_develop: ${{ github.ref == 'refs/heads/develop' }} is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }} - is_gitflow_sync: ${{ github.head_ref == 'refs/heads/develop' || github.head_ref == 'refs/heads/master' }} + # When merging into master, or from master + is_gitflow_sync: ${{ github.head_ref == 'refs/heads/master' || github.ref == 'refs/heads/master' }} has_gitflow_label: ${{ github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' Gitflow ') }} force_skip_cache: diff --git a/.github/workflows/gitflow-sync-master.yml b/.github/workflows/gitflow-sync-master.yml deleted file mode 100644 index 6582bbede98a..000000000000 --- a/.github/workflows/gitflow-sync-master.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Gitflow - Sync develop into master -on: - pull_request: - types: - - closed - branches: - - develop - -env: - MAIN_BRANCH: master - -jobs: - main: - name: Create PR develop->master - runs-on: ubuntu-20.04 - if: | - github.event.pull_request.merged == true && - startsWith(github.event.pull_request.title, 'meta(changelog):') - permissions: - pull-requests: write - contents: write - steps: - - name: git checkout - uses: actions/checkout@v3 - - # https://github.com/marketplace/actions/github-pull-request-action - - name: Create Pull Request - id: open-pr - uses: repo-sync/pull-request@v2 - with: - destination_branch: ${{ env.MAIN_BRANCH }} - pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.MAIN_BRANCH }}' - pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.MAIN_BRANCH }}' - pr_label: 'Dev: Gitflow' - # This token is scoped to Daniel Griesser - github_token: ${{ secrets.REPO_SCOPED_TOKEN }} - - # https://github.com/marketplace/actions/enable-pull-request-automerge - - name: Enable automerge for PR - if: steps.open-pr.outputs.pr_number != '' - uses: peter-evans/enable-pull-request-automerge@v2 - with: - pull-request-number: ${{ steps.open-pr.outputs.pr_number }} - merge-method: merge - - # https://github.com/marketplace/actions/auto-approve - - name: Auto approve PR - # Always skip this for now, until we got a proper bot setup - if: steps.open-pr.outputs.pr_number != '' - uses: hmarr/auto-approve-action@v3 - with: - pull-request-number: ${{ steps.open-pr.outputs.pr_number }} - review-message: 'Auto approved automated PR' - - skipped: - runs-on: ubuntu-20.04 - if: | - github.event.pull_request.merged == false || - startsWith(github.event.pull_request.title, 'meta(changelog):') == false - steps: - - name: Sync skipped - run: echo "OK" diff --git a/docs/publishing-a-release.md b/docs/publishing-a-release.md index 642fd2e51899..ff94e6165ea8 100644 --- a/docs/publishing-a-release.md +++ b/docs/publishing-a-release.md @@ -6,20 +6,20 @@ _These steps are only relevant to Sentry employees when preparing and publishing **If you want to release a new SDK for the first time, be sure to follow the [New SDK Release Checklist](./new-sdk-release-checklist.md)** 1. Determine what version will be released (we use [semver](https://semver.org)). -2. Update [`CHANGELOG.md`](https://github.com/getsentry/sentry-javascript/edit/master/CHANGELOG.md) to add an entry for the next release number and a list of changes since the last release. (See details below.) - a. Merging the Changelog PR will automatically trigger a sync from `develop` -> `master` -3. Run the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) workflow. - a. Wait for this until the sync to `master` is completed. -4. A new issue should appear in https://github.com/getsentry/publish/issues. -5. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release. +2. Create a branch `prepare-release/VERSION`, eg. `prepare-release/7.37.0`, off develop +3. Update [`CHANGELOG.md`](https://github.com/getsentry/sentry-javascript/edit/master/CHANGELOG.md) to add an entry for the next release number and a list of changes since the last release. (See details below.) +4. Create a PR towards `master` branch +5. When the PR is merged, it will automatically trigger the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) on master. +6. A new issue should appear in https://github.com/getsentry/publish/issues. +7. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release. a. Once the release is completed, a sync from `master` ->` develop` will be automatically triggered ## Updating the Changelog -1. Create a new branch. +1. Create a new branch `prepare-release/VERSION` off of `develop`, e.g. `prepare-release/7.37.1`. 2. Run `yarn changelog` and copy everything 3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release. 4. Paste in the logs you copied earlier. 5. Delete any which aren't user-facing changes. 7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by . Thank you for your contributions!`. If there's only one external PR, don't forget to remove the final `s`. If there are three or more, use an Oxford comma. (It's in the Sentry styleguide!) -8. Commit, push, and open a PR with the title `meta: Update changelog for ` against `develop` branch. +8. Commit, push, and open a PR with the title `meta(changelog): Update changelog for VERSION` against `master` branch.