Skip to content

Commit 121c2c9

Browse files
authored
ci: Setup gitflow process (#6890)
1 parent 00482d8 commit 121c2c9

10 files changed

+161
-31
lines changed

.github/workflows/build.yml

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Build & Test'
22
on:
33
push:
44
branches:
5-
- master
5+
- develop
66
- release/**
77
pull_request:
88
workflow_dispatch:
@@ -42,11 +42,11 @@ env:
4242

4343
# GH will use the first restore-key it finds that matches
4444
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
45-
# We want to prefer the cache from the current master branch, if we don't find any on the current branch
45+
# We want to prefer the cache from the current develop branch, if we don't find any on the current branch
4646
NX_CACHE_RESTORE_KEYS: |
4747
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
4848
nx-Linux-${{ github.ref }}
49-
nx-Linux-refs/heads/master
49+
nx-Linux-refs/heads/develop
5050
nx-Linux
5151
5252
jobs:
@@ -134,7 +134,7 @@ jobs:
134134
changed_browser_integration: ${{ steps.changed.outputs.browser_integration }}
135135
changed_any_code: ${{ steps.changed.outputs.any_code }}
136136
# Note: These next three have to be checked as strings ('true'/'false')!
137-
is_master: ${{ github.ref == 'refs/heads/master' }}
137+
is_develop: ${{ github.ref == 'refs/heads/develop' }}
138138
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
139139
force_skip_cache:
140140
${{ github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ') }}
@@ -202,7 +202,7 @@ jobs:
202202
- name: NX cache
203203
uses: actions/cache@v3
204204
# Disable cache when:
205-
# - on master
205+
# - on develop
206206
# - on release branches
207207
# - when PR has `ci-skip-cache` label
208208
if: |
@@ -211,9 +211,9 @@ jobs:
211211
with:
212212
path: node_modules/.cache/nx
213213
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }}
214-
# On master branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
214+
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
215215
restore-keys:
216-
${{needs.job_get_metadata.outputs.is_master == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
216+
${{needs.job_get_metadata.outputs.is_develop == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
217217

218218
- name: Build packages
219219
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
@@ -272,8 +272,7 @@ jobs:
272272
needs: [job_get_metadata, job_build]
273273
timeout-minutes: 15
274274
runs-on: ubuntu-20.04
275-
# Size Check will error out outside of the context of a PR or master branch
276-
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true'
275+
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_develop == 'true'
277276
steps:
278277
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
279278
uses: actions/checkout@v3
@@ -283,7 +282,6 @@ jobs:
283282
uses: actions/setup-node@v3
284283
with:
285284
# The size limit action runs `yarn` and `yarn build` when this job is executed on
286-
# `master`. We can't change this without making changes to the action, so we'll
287285
# use Node 14 for now.
288286
node-version: '14'
289287
- name: Check dependency cache
@@ -301,6 +299,7 @@ jobs:
301299
with:
302300
github_token: ${{ secrets.GITHUB_TOKEN }}
303301
skip_step: build
302+
main_branch: develop
304303

305304
job_lint:
306305
name: Lint

.github/workflows/codeql-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ name: 'CodeQL'
1313

1414
on:
1515
push:
16-
branches: [master]
16+
branches: [develop]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [master]
19+
branches: [develop]
2020
paths-ignore:
2121
# When _only_ changing .md files, no need to run CodeQL analysis
2222
- '**/*.md'

.github/workflows/enforce-license-compliance.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Enforce License Compliance
22

33
on:
44
push:
5-
branches: [master, main, release/*]
5+
branches: [master, develop, release/*]
66
pull_request:
7-
branches: [master, main]
7+
branches: [master, develop]
88

99
jobs:
1010
enforce-license-compliance:
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Gitflow - Sync master into develop
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
# When the version is updated on master (but nothing else)
8+
- 'lerna.json'
9+
- '!**/*.js'
10+
- '!**/*.ts'
11+
workflow_dispatch:
12+
13+
env:
14+
DEV_BRANCH: develop
15+
16+
jobs:
17+
main:
18+
name: Create PR master->develop
19+
runs-on: ubuntu-20.04
20+
permissions:
21+
pull-requests: write
22+
steps:
23+
- name: git checkout
24+
uses: actions/checkout@v3
25+
26+
# https://github.com/marketplace/actions/github-pull-request-action
27+
- name: Create Pull Request
28+
id: open-pr
29+
uses: repo-sync/pull-request@v2
30+
with:
31+
destination_branch: ${{ env.DEV_BRANCH }}
32+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.DEV_BRANCH }}'
33+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.DEV_BRANCH }}'
34+
35+
# https://github.com/marketplace/actions/enable-pull-request-automerge
36+
- name: Enable automerge for PR
37+
if: steps.open-pr.outputs.pr_number != ''
38+
uses: peter-evans/enable-pull-request-automerge@v2
39+
with:
40+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
41+
merge-method: merge
42+
43+
# https://github.com/marketplace/actions/auto-approve
44+
- name: Auto approve PR
45+
uses: hmarr/auto-approve-action@v3
46+
with:
47+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
48+
review-message: 'Auto approved automated PR'
49+
# TODO: Use the token of some user here??
50+
# github-token: ${{ secrets.SOME_USERS_PAT }}
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Gitflow - Sync develop into master
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
paths:
7+
# We want to trigger this when ONLY the changlog is changed on develop, but nothing else
8+
- 'CHANGELOG.md'
9+
- '!packages'
10+
- '!**/*.js'
11+
- '!**/*.json'
12+
- '!**/*.ts'
13+
workflow_dispatch:
14+
15+
env:
16+
MAIN_BRANCH: master
17+
18+
jobs:
19+
main:
20+
name: Create PR develop->master
21+
runs-on: ubuntu-20.04
22+
permissions:
23+
pull-requests: write
24+
steps:
25+
- name: git checkout
26+
uses: actions/checkout@v3
27+
28+
# https://github.com/marketplace/actions/github-pull-request-action
29+
- name: Create Pull Request
30+
id: open-pr
31+
uses: repo-sync/pull-request@v2
32+
with:
33+
destination_branch: ${{ env.MAIN_BRANCH }}
34+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.MAIN_BRANCH }}'
35+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.MAIN_BRANCH }}'
36+
37+
# https://github.com/marketplace/actions/enable-pull-request-automerge
38+
- name: Enable automerge for PR
39+
if: steps.open-pr.outputs.pr_number != ''
40+
uses: peter-evans/enable-pull-request-automerge@v2
41+
with:
42+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
43+
merge-method: merge
44+
45+
# https://github.com/marketplace/actions/auto-approve
46+
- name: Auto approve PR
47+
uses: hmarr/auto-approve-action@v3
48+
with:
49+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
50+
review-message: 'Auto approved automated PR'
51+
# TODO: Use the token of some user here??
52+
# github-token: ${{ secrets.SOME_USERS_PAT }}

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
merge_target:
1212
description: Target branch to merge into. Uses the default branch as a fallback (optional)
1313
required: false
14+
default: master
1415
jobs:
1516
release:
1617
runs-on: ubuntu-20.04

CONTRIBUTING.md

+6-17
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,14 @@ This means that all commits on the branch will be squashed into a single commit,
130130
* Make sure to rebase the branch on `master` before squashing it
131131
* Make sure to update the commit message of the squashed branch to follow the commit guidelines - including the PR number
132132
133-
## Publishing a Release
133+
### Gitflow
134134
135-
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
135+
We use [Gitflow](https://docs.github.com/en/get-started/quickstart/github-flow) as a branching model.
136136
137-
**If you want to release a new SDK for the first time, be sure to follow the [New SDK Release Checklist](./docs/new-sdk-release-checklist.md)**
137+
For more details, [see our Gitflow docs](./docs/gitflow.md).
138138
139-
1. Determine what version will be released (we use [semver](https://semver.org)).
140-
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.)
141-
3. Run the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) workflow.
142-
4. A new issue should appear in https://github.com/getsentry/publish/issues.
143-
5. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release.
139+
## Publishing a Release
144140
145-
### Updating the Changelog
141+
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
146142
147-
1. Create a new branch.
148-
2. Run `git log --format="- %s"` and copy everything since the last release.
149-
3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release.
150-
4. Paste in the logs you copied earlier.
151-
5. Delete any which aren't user-facing changes.
152-
6. Alphabetize the rest.
153-
7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by <list of external contributors' GitHub usernames>. 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!)
154-
8. Commit, push, and open a PR with the title `meta: Update changelog for <fill in relevant version here>`.
143+
[See the docs for publishing a release](./docs/publishing-a-release.md)

docs/assets/gitflow-chart.png

36.6 KB
Loading

docs/gitflow.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gitflow
2+
3+
We use [Gitflow](https://docs.github.com/en/get-started/quickstart/github-flow) as a branching model.
4+
5+
## Summary
6+
7+
* Ongoing work happens on the `develop` branch
8+
* Any PRs (features, ...) are implemented as PRs against `develop`
9+
* When we are ready to release, we merge develop into master, create a release there, then merge master back into develop
10+
* Whatever is currently on `master` can be considered the last released state of the SDK
11+
* Never merge directly into `master` (unless we want e.g. an emergency bugfix release)
12+
13+
![gitflow-chart](./assets/gitflow-chart.png)

docs/publishing-a-release.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Publishing a Release
3+
4+
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
5+
6+
**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)**
7+
8+
1. Determine what version will be released (we use [semver](https://semver.org)).
9+
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.)
10+
a. Merging the Changelog PR will automatically trigger a sync from `develop` -> `master`
11+
3. Run the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) workflow.
12+
a. Wait for this until the sync to `master` is completed.
13+
4. A new issue should appear in https://github.com/getsentry/publish/issues.
14+
5. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release.
15+
a. Once the release is completed, a sync from `master` ->` develop` will be automatically triggered
16+
17+
## Updating the Changelog
18+
19+
1. Create a new branch.
20+
2. Run `git log --format="- %s"` and copy everything since the last release.
21+
3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release.
22+
4. Paste in the logs you copied earlier.
23+
5. Delete any which aren't user-facing changes.
24+
6. Alphabetize the rest.
25+
7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by <list of external contributors' GitHub usernames>. 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!)
26+
8. Commit, push, and open a PR with the title `meta: Update changelog for <fill in relevant version here>` against `develop` branch.

0 commit comments

Comments
 (0)