-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: semantic release #746
Merged
Merged
Changes from 38 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
87f854f
chore: fix repo url field
kanadgupta 266787d
chore(deps-dev): install semantic-release, initial config
kanadgupta 73fce60
chore(deps-dev): add husky + commitlint
kanadgupta c8d995d
Merge branch 'main' into semantic-release
kanadgupta 100f7fc
ci: add release.yml
kanadgupta 076cfbf
feat: fix comment
kanadgupta 5870124
chore: temporarily disable dryrun :meow-sweat:
kanadgupta ce4e494
fix: next channel
kanadgupta 3eb52fd
fix: remove some of the package scripts
kanadgupta d8a722f
chore: restore dry runs
kanadgupta 85e4bfd
feat: add git + changelog plugins
kanadgupta baa1705
chore(temp): disable dry-run
kanadgupta 11799e1
build(release): ๐ v8.6.0-next.2 release ๐ฆ
semantic-release-bot 1ba8bdd
chore: little bits of cleanup
kanadgupta 29b9ec6
fix: rebuild prior to npm publish
kanadgupta 38c5625
fix: reformat github release header
kanadgupta 836a9f2
build(release): ๐ v8.6.0-next.3 ๐ฆ
semantic-release-bot bd2e1a2
fix: reformat header again
kanadgupta 4c34207
feat: drop duplicative tag
kanadgupta 523310f
build(release): ๐ v8.6.0-next.4 ๐ฆ
semantic-release-bot 05300e7
chore: remove github release npm script
kanadgupta f9fe6c6
Revert "feat: drop duplicative tag"
kanadgupta cac0c1d
fix: try rearranging steps like this
kanadgupta f0b241c
build(release): ๐ v8.6.0-next.5 ๐ฆ
semantic-release-bot 194489e
revert: don't set header for changelog
kanadgupta 8463946
chore: add comment
kanadgupta e77b67a
Revert "chore: remove github release npm script"
kanadgupta 1825c27
chore(deps-dev): install @semantic-release/exec
kanadgupta 24f885e
fix: run tests but NOT release workflow on release commits
kanadgupta bb91531
chore: add another comment
kanadgupta 8c343a0
fix: try this as an alternative to @semantic-release/github
kanadgupta 533a2db
build(release): ๐ v8.6.0-next.6 ๐ฆ
semantic-release-bot 5f05aea
refactor: get rid of npm script
kanadgupta f277c47
chore: add comment
kanadgupta 53dbd02
chore: remove another now-redundant npm script
kanadgupta 7581049
chore: c'mon man
kanadgupta dda580e
docs: update MAINTAINERS.md
kanadgupta 1b547dc
chore: cleanup
kanadgupta b067e01
chore: fix up a few GHA branch setups
kanadgupta b28c936
chore: remove a redundant rules
kanadgupta 0b1e429
revert: ugh here we go again
kanadgupta 4e5ecff
fix: try this approach to lifecycle events
kanadgupta f9f82f1
fix: turns out these rules weren't redundant
kanadgupta 793de2b
build(release): ๐ v8.6.0-next.7 ๐ฆ
semantic-release-bot c81e432
fix: does this work?
kanadgupta a211647
chore: cleanup + cache
kanadgupta 05af285
build(release): ๐ v8.6.0-next.8 ๐ฆ
semantic-release-bot c07495a
revert: bring workflow name back
kanadgupta df5f238
chore: use this convention instead
kanadgupta eec7a2e
chore: ok stop this now
kanadgupta c22889c
fix: remove unnecessary config
kanadgupta c9a2910
Merge branch 'next' into semantic-release
kanadgupta b04a8ce
Merge branch 'next' into semantic-release
kanadgupta 1629acb
Merge branch 'next' into semantic-release
kanadgupta e15c574
fix: bad merge
kanadgupta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- next | ||
|
||
jobs: | ||
release: | ||
if: "!contains(github.event.head_commit.message, '[skip release ci]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- name: Install dependencies and build TS | ||
run: npm ci && npm run build | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
branches: [main, next] | ||
plugins: | ||
- '@semantic-release/commit-analyzer' | ||
- ['@semantic-release/release-notes-generator', { 'writerOpts': { 'commitsSort': ['subject', 'scope'] } }] | ||
- '@semantic-release/changelog' | ||
- [ | ||
'@semantic-release/git', | ||
{ | ||
# TODO: once docker builds are a thing, we're going to have to manually add the assets | ||
# since we're also updating the action.yml file with every release! | ||
# Uncomment this line below once those changes are live: | ||
# assets: ['action.yml', 'CHANGELOG.md', 'package.json', 'package-lock.json'], | ||
message: "build(release): ๐ v${nextRelease.version} ๐ฆ\n\n${nextRelease.notes}\n[skip release ci]", | ||
}, | ||
] | ||
# `npm` must be after `git` because we need the `prepare`step of the `git` plugin | ||
# to execute first so it can create the build commit since we do some add'l tagging | ||
# in the `postversion` npm hook | ||
- '@semantic-release/npm' | ||
# Lightweight alternative to `@semantic-release/github` that creates a draft release | ||
- ['@semantic-release/exec', { 'publishCmd': 'gh release create ${nextRelease.version} --draft --generate-notes' }] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
# Maintainers | ||
|
||
This doc describes how to prep a release and publish to GitHub and `npm`. | ||
This doc describes how releases are published to GitHub and `npm`. | ||
|
||
## Prep the Release | ||
## Automatic Packaging + Publishing ๐ฆ | ||
|
||
Run the following command, where `<version>` is the version you wish to update the package to: | ||
Nearly all of our release process is automated. In this section, we discuss everything that takes place! | ||
|
||
```sh | ||
npm run bump -- <version> | ||
``` | ||
> **Note** | ||
> You don't _need_ to know everything that takes place here, this is mostly for my own documentation purposes! But if you are tagging an actual release, there are a couple of outstanding steps that are described in [the next section](#one-more-thing-โ๏ธ) ๐ | ||
|
||
This command will automatically bump the version in the `package.json` and the `package-lock.json` files, update [`CHANGELOG.md`](./CHANGELOG.md), and add the corresponding git tags. | ||
When code is merged into the `main` or `next` branches, a release workflow (powered by [`semantic-release`](https://github.com/semantic-release/semantic-release)) automatically kicks off that does the following: | ||
|
||
## Publishing to GitHub :octopus: | ||
- All commit messages since the last release are analyzed to determine whether or not the new changes warrant a new release (i.e., if the changes are features or fixes as opposed to smaller housekeeping changes) ๐ง | ||
- Based on the changes, the version is bumped in [`package.json`](./package.json) with a new git tag ๐ท๏ธ For example, say the current version is `8.5.1` and the commit history includes a new feature. This would result in a minor semver bump, which would produce the following tags: | ||
- A release tag like `v8.6.0` if on the `main` branch | ||
- A prerelease tag like `v8.6.0-next.1` if on the `next` branch | ||
- A changelog is generated and appended to [`CHANGELOG.md`](./CHANGELOG.md) ๐ชต | ||
- A build commit (like [this](https://github.com/readmeio/rdme/commit/533a2db50b39c3b6130b3af07bebaed38218db4c)) is created with the updated `package*.json` and `CHANGELOG.md` files ๐ | ||
- A couple duplicated tags are created for the current commit so our users can refer to them differently in their GitHub Actions (e.g., `8.6.0`, `v8`) ๐ | ||
- The new commit and tags are pushed to GitHub ๐ | ||
- The new version is published to the `npm` registry ๐ The package [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) will depend on which branch is being pushed to: | ||
- If on the `main` branch, a version is pushed on the main distribution tag (a.k.a. `latest`, which is used when someone runs `npm i rdme` with no other specifiers). | ||
- If on the `next` branch, the prerelease distribution tag (a.k.a. [`next`](https://www.npmjs.com/package/rdme/v/next)) is updated. | ||
- A [GitHub release is created](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) for the tag (in draft form) ๐ | ||
|
||
The next step is to push these changes to GitHub: | ||
## One more thing โ๏ธ | ||
|
||
```sh | ||
git push # pushes the code | ||
git push --tags -f # pushes the tags | ||
``` | ||
> **Note** | ||
> The steps in this section are only required if you're building an actual release and not a prelease (i.e., changes are being merged into the `main` branch). | ||
|
||
Once the code and tags are pushed to GitHub, [create a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) so the latest tag is surfaced in [the GitHub Marketplace listing](https://github.com/marketplace/actions/rdme-sync-to-readme). | ||
While nearly all of our release process is automated, there are a couple quick steps remaining: | ||
|
||
Make sure you have the [GitHub CLI](https://cli.github.com) installed and then run the following: | ||
1. **Backport the changes in the `main` branch back into `next`** ๐ you can do so by running the following: | ||
|
||
```sh | ||
npm run release:gh | ||
git checkout next | ||
git merge main | ||
git push | ||
``` | ||
|
||
This will create a draft release which you can enhance before publishing. I like to summarize the changes and note any highlights in a blurb above the auto-generated release notes. These release links are nice for sharing with customers, on socials, etc. | ||
|
||
## Publishing to `npm` :rocket: | ||
|
||
Finally, publish the changes to `npm`. If you're publishing to a non-standard [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) for prelease purposes or otherwise (e.g., `alpha`, `beta`, `next`, etc.), you can run the following: | ||
|
||
```sh | ||
npm publish --tag <tag> | ||
``` | ||
|
||
If you're publishing to the default [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) (i.e., `latest`), you can omit the `--tag` flag like so: | ||
|
||
```sh | ||
npm publish | ||
``` | ||
2. **Fluff out the GitHub release and publish it** โ๏ธ the GitHub release is currently in draft form but it needs to be published so the latest version is surfaced to folks that discover our tool via [the GitHub Marketplace listing](https://github.com/marketplace/actions/rdme-sync-to-readme). I like to summarize the changes and note any highlights in a blurb above the auto-generated release notes. These release links are nice for sharing with customers, on socials, etc. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that the GitHub CLI is pre-installed on GitHub Actions runners: https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows