Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #58 from getsentry/ab/changelog-script
Browse files Browse the repository at this point in the history
chore(release): Add changelog script, autorelease action and docs for publishing a release
  • Loading branch information
andreiborza authored Jul 4, 2024
2 parents 88b5645 + 219b58f commit 35b1196
Show file tree
Hide file tree
Showing 9 changed files with 3,036 additions and 2,340 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Auto release"
on:
pull_request:
types:
- closed
branches:
- main

# This workflow triggers a release when merging a branch with the pattern `prepare-release/VERSION` into main.
jobs:
release:
runs-on: ubuntu-latest
name: 'Prepare a new version'
if: startsWith(github.head_ref, 'prepare-release/')
steps:
- uses: actions/checkout@v4
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-regex
with:
# Parse version from head branch
text: ${{ github.head_ref }}
# match: preprare-release/xx.xx.xx
regex: '^prepare-release\/(\d+\.\d+\.\d+)(?:-(alpha|beta|rc)\.\d+)?$'

- name: Extract version
id: get_version
run: |
version=${{ steps.version-regex.outputs.match }}
version=${version/'prepare-release/'/''}
echo "version=$version" >> $GITHUB_OUTPUT
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Prepare release
uses: getsentry/action-prepare-release@lms/write-config-branch
if: github.event.pull_request.merged == true && steps.version-regex.outputs.match != '' && steps.get_version.outputs.version != ''
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
with:
version: ${{ github.event.inputs.version }}
force: ${{ github.event.inputs.force }}
merge_target: main
craft_config_from_merge_target: true
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
runs-on: ubuntu-latest
name: 'Release a new version'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
node_modules
tmp
26 changes: 26 additions & 0 deletions docs/publishing-a-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Publishing a Release

_These steps are only relevant to Sentry employees when preparing and publishing a new release._

1. Run `pnpm changelog` on the `main` branch and determine what version will be released (we use
[semver](https://semver.org))
2. Create a branch `prepare-release/VERSION`, e.g. `prepare-release/1.4.8`, off of main
3. Update [`CHANGELOG.md`](https://github.com/getsentry/sentry-migr8/edit/main/CHANGELOG.md) to add an entry for
the next release number and a list of changes since the last release. (See details below.)
4. Open a PR with the title `meta(changelog): Update changelog for VERSION` against the `main` branch.
5. **Be cautious!** The PR against `master` should be merged via "Merge Commit"
6. When the PR is merged, it will automatically trigger the
[Auto Release](https://github.com/getsentry/sentry-migr8/actions/workflows/auto-release.yml) on main.

## Updating the Changelog

1. Run `pnpm changelog` and copy everything.
2. Create a new section in the changelog with the previously determined version number.
3. Paste in the logs you copied earlier.
4. Highlight any important changes with subheadings.
5. 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!)
6. Commit, push, and continue with step 4 from the previous section with the general instructions (above).

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"fix:prettier": "prettier --write \"{src,test-helpers,test-fixtures}/**/*.js\"",
"dev": "node ./src/index.js",
"test": "vitest run",
"test:e2e": "vitest run ./src/index.test.js"
"test:e2e": "vitest run ./src/index.test.js",
"changelog": "pnpx tsx ./scripts/get-commit-list.ts"
},
"dependencies": {
"@clack/prompts": "^0.7.0",
Expand Down
Loading

0 comments on commit 35b1196

Please sign in to comment.