Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: setup conventional commits & release automation (#673)
## Purpose of the changes In order to improve the maintainability and velocity of this project, I suggested we implement an automatic release pipeline. To support this automation feature, I've set up the repository to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) formatting standard. This allows any commit to be parsed programmatically, and the release type (major, minor, patch) associated with a group of new commits to be determined automatically. For more information on the different commit types and their associated releases, please check [the table listing from the configuration preset](https://github.com/insurgent-lab/conventional-changelog-preset#commit-types). Once those changes are merged to `master`: - new commits on `master` will automatically be linted (locally with a pre-commit hook) to ensure they follow the formatting standard. - commits on other branches won't be linted, instead, the PR title will be linted (removing overhead for contributors). If the PR title isn't compliant, an explanation message will automatically be posted on the PR. - any commit pushed to the `master` branch will trigger a Test & Release workflow (unless `[skip ci]` is present in the commit title) that will analyze the commits since the last version, automatically determine the necessary version bump, and handle the whole release process (updating `package.json` & `package-lock.json`, generating new `CHANGELOG.md` entries, publishing Github tag & release, then publishing the new version to npm). ## Todo before merging the PR: - [x] create a git tag for v2.3.1 (pointing to 988f7f2) - [x] only allow squash merging PRs (cf screenshot below) - go to https://github.com/kelektiv/node-cron/settings#merge-button-settings - check "Allow squash merging" and set the below dropdown to "Default to pull request title" - uncheck "Allow merge commits" & "Allow rebase merging" - [x] setup branch protection for `master` (cf screenshot below) - go to https://github.com/kelektiv/node-cron/settings/branches and create/update branch protection for `master` with (at least) the following options: - "Require a pull request before merging" - "Dismiss stale pull request approvals when new commits are pushed" - "Require status checks to pass before merging" - "Require branches to be up to date before merging" > then find and select all "lint-and-test" workflows (should be 9 of them + "Lint PR title" + "security/snyk"). - "Require conversation resolution before merging" - "Require linear history" - make sure "Do not allow bypassing the above settings" is **unchecked**, else the automatic release commits won't work - [x] setup Github PAC for the repository (required because of [limitations with the default access token when branch protection is enabled](semantic-release/github#175)) - go to https://github.com/settings/personal-access-tokens/new - set Expiration in one year (custom) - select the right resource owner (should be "kelektiv") - under "Repository" access, select "Only select repositories" and select only "node-cron" - under "Permissions", set "Contents", "Issues" and "Pull requests" to "Read and write" - the "Overview" section should look like this (cf screenshot below) - copy the generated token to a new `CI_GITHUB_TOKEN` repository secret on the Github repository - [x] setup npm token for the package - go to https://www.npmjs.com/settings/{NPM_USERNAME}/tokens - "Generate New Token" > "Granular Access Token" - set Expiration to "365 days" - set Permissions to "Read and write", then click on "Only select packages and scopes" and select only "cron" - copy the generated token to a new `NPM_TOKEN` repository secret on the Github repository ## Screenshots <details> <summary>disable merge commits in PR, only allow squash merging</summary> ![image](https://github.com/kelektiv/node-cron/assets/11234273/96e8eb3e-125a-4ce5-9a45-8289a0cdfc19) </details> <details> <summary>setup branch protection for `master` *(required checks are not exactly the same in the screenshot)*</summary> ![image](https://github.com/kelektiv/node-cron/assets/11234273/bdb712b0-9a62-4391-a85b-6ee762797232) </details> <details> <summary>Github PAC > the "Overview" section should look like this</summary> ![image](https://github.com/kelektiv/node-cron/assets/11234273/0fb4b9ef-8674-42c2-af4a-bf89776239a4) </details> ## Notes - The "Squash and Merge" button should be the only one available when trying to merge this PR.
- Loading branch information