-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from ERC725Alliance/develop
Update main branch to sync latest docs
- Loading branch information
Showing
23 changed files
with
189 additions
and
193 deletions.
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 |
---|---|---|
@@ -1,101 +1,59 @@ | ||
# If it detects a version bump on main, it will trigger a release. | ||
# If the workflow is started manually, it will skip the bump detection and attempt to publish. | ||
name: Release and publish | ||
name: Create GitHub release and publish to NPM | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
release: | ||
release-please: | ||
name: 📦 Create GitHub release and publish to NPM | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Ensure main branch | ||
if: github.ref != 'refs/heads/main' | ||
run: |- | ||
echo "Not running on main - exit" | ||
exit 1 | ||
|
||
- uses: actions/checkout@v2 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 🔍 Check if version changed | ||
uses: EndBug/version-check@v1 | ||
if: github.event_name == 'push' | ||
id: check | ||
|
||
- name: 🔄 Check if should release | ||
run: echo "SHOULD_RELEASE=${{ steps.check.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' }}" >> $GITHUB_ENV | ||
|
||
- name: ⚙️ Setup Node.js v16 | ||
uses: actions/setup-node@v2 | ||
if: env.SHOULD_RELEASE == 'true' | ||
with: | ||
node-version: '16.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
scope: '@erc725' | ||
cache: 'npm' | ||
|
||
- name: 📝 Set Version | ||
if: env.SHOULD_RELEASE == 'true' | ||
run: |- | ||
APP_VERSION="v$(node -pe "require('./package.json').version")" | ||
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV | ||
- name: 🧰 Install | ||
if: env.SHOULD_RELEASE == 'true' | ||
run: npm ci | ||
|
||
- name: 💅 Lint | ||
run: npm run lint | ||
|
||
- name: 🎯 Test | ||
if: env.SHOULD_RELEASE == 'true' | ||
run: npm test | ||
|
||
- name: 🛠 Build | ||
if: env.SHOULD_RELEASE == 'true' | ||
run: npm run build | ||
|
||
# We assume this will be always triggered by a merge from develop | ||
# Therefore we tag the previous commit (the merge commit won't be on develop) | ||
- name: 🏷 Create and push Git Tag | ||
if: env.SHOULD_RELEASE == 'true' | ||
run: |- | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "LUKSO Bot" | ||
git tag -a ${{ env.APP_VERSION }} HEAD~ -m "Release Version ${{ env.APP_VERSION }} [CI]" | ||
git push --set-upstream origin tag ${{ env.APP_VERSION }} | ||
# Create GitHub Release | ||
- name: 📝 Extract release notes from CHANGELOG | ||
if: env.SHOULD_RELEASE == 'true' | ||
id: extract-release-notes | ||
uses: ffurrer2/extract-release-notes@v1 | ||
with: | ||
release_notes_file: RELEASENOTES.md | ||
|
||
- uses: jwalton/gh-find-current-pr@v1 | ||
if: env.SHOULD_RELEASE == 'true' | ||
id: findPR | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
state: closed | ||
release-type: node | ||
package-name: '@erc725/erc725.js' | ||
bump-minor-pre-major: true | ||
default-branch: main | ||
|
||
- name: Add PR body to Release Notes | ||
if: env.SHOULD_RELEASE == 'true' | ||
env: | ||
PR_BODY: ${{ steps.findPR.outputs.body }} | ||
run: |- | ||
echo ${PR_BODY}|cat - RELEASENOTES.md > /tmp/out && mv /tmp/out RELEASENOTES.md | ||
- name: 🔍 Check if version changed | ||
uses: EndBug/version-check@v1 | ||
if: github.event_name == 'push' | ||
id: check | ||
|
||
- name: 🚀 Create GitHub release | ||
uses: ncipollo/release-action@v1 | ||
if: env.SHOULD_RELEASE == 'true' | ||
with: | ||
bodyFile: 'RELEASENOTES.md' | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ env.APP_VERSION }} | ||
- name: 🔄 Check if should release | ||
run: echo "SHOULD_RELEASE=${{ steps.check.outputs.changed == 'true' }}" >> $GITHUB_ENV | ||
|
||
- name: 📦 Publish to NPM | ||
if: env.SHOULD_RELEASE == 'true' | ||
|
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,60 +1,63 @@ | ||
# Release Process | ||
|
||
Releases are published to NPM when `develop` is merged into `main` AND when the merged code contains a version bump in the `package.json`. | ||
Releases are published to npm using [Release Please](https://github.com/googleapis/release-please). | ||
|
||
## Create and publish a new release: | ||
This package automates CHANGELOG generation, version bumps and npm releases by parsing the | ||
git history, looking for [Conventional Commit messages](https://www.conventionalcommits.org/). | ||
|
||
### Bump version | ||
When changes and feature PRs are merged from develop to main, `release-please` will open and maintain a release PR with the updated CHANGELOG and new version number. When this PR is merged, a release will be created and the package published to NPM. | ||
|
||
You can manually trigger the [Bump version](https://github.com/ERC725Alliance/erc725.js/actions/workflows/bump-version.yml) workflow from the `develop` branch. | ||
1. Merge develop into main. | ||
2. Release Please will create the release PR going to main. | ||
3. Merge the generated release PR. | ||
4. Package will be published to NPM. | ||
|
||
To bump locally: | ||
## Conventional Commit prefixes? | ||
|
||
1. Checkout to a new release branch from `develop`. | ||
2. Bump version with [standard-version](https://github.com/conventional-changelog/standard-version). To create pre-release or specific versions, see below. | ||
Commits should follow the [Conventional Commit messages standard](https://www.conventionalcommits.org/). | ||
|
||
```bash | ||
npm run release | ||
``` | ||
3. Push the changes to origin. A git tag is created by the release CI so do **not** push tags here. | ||
|
||
```bash | ||
git push origin | ||
``` | ||
The following commit prefixes will result in changes in the CHANGELOG: | ||
|
||
4. Open a PR from your release branch to `develop` and merge it. | ||
- `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) | ||
patch. | ||
- `feat:` which represents a new feature, and correlates to a minor version increase. | ||
(indicated by the `!`) and will result in a SemVer major version increase. | ||
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change | ||
- `build:` Changes that affect the build system or external dependencies. | ||
- `ci:` Changes to our CI configuration files and scripts. | ||
- `docs:` Documentation only changes. | ||
- `perf:` A code change that improves performance. | ||
- `refactor:` A code change that neither fixes a bug nor adds a feature. | ||
- `style:` Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). | ||
- `test:` Adding missing tests or correcting existing tests. | ||
- `chore:` Other | ||
|
||
### Release | ||
## Release with a custom version number | ||
|
||
- Merge `develop` into `main` through a PR. | ||
- The CI will create a GitHub release and publish to NPM. | ||
When a commit to the main branch has `Release-As: x.x.x` (case insensitive) in the **commit body**, Release Please will open a new pull request for the specified version. | ||
|
||
If it fails, you can manually trigger the workflow from the [Actions](https://github.com/ERC725Alliance/erc725.js/actions/workflows/release.yml) tab. | ||
`git commit --allow-empty -m "chore: release 2.0.0" -m "Release-As: 2.0.0"` results in the following commit message: | ||
|
||
## Specific Version Increases | ||
```txt | ||
chore: release 2.0.0 | ||
To ignore the automatic version increase in favour of a custom version use the `--release-as` flag with the argument `major`, `minor` or `patch` or a specific version number: | ||
|
||
```bash | ||
npm run release -- --release-as minor | ||
# Or | ||
npm run release -- --release-as 1.1.0 | ||
Release-As: 2.0.0 | ||
``` | ||
|
||
## Prerelease versions | ||
## How can I fix release notes? | ||
|
||
To create a pre-release run: | ||
If you have merged a pull request and would like to amend the commit message | ||
used to generate the release notes for that commit, you can edit the body of | ||
the merged pull requests and add a section like: | ||
|
||
```bash | ||
npm run release -- --prerelease | ||
``` | ||
BEGIN_COMMIT_OVERRIDE | ||
feat: add ability to override merged commit message | ||
If the lastest version is 1.0.0, the pre-release command will change the version to: `1.0.1-0` | ||
|
||
To name the pre-release, set the name by adding `--prerelease <name>` | ||
|
||
```bash | ||
npm run release -- --prerelease alpha | ||
fix: another message | ||
chore: a third message | ||
END_COMMIT_OVERRIDE | ||
``` | ||
|
||
If the latest version is 1.0.0 this will change the version to: `1.0.1-alpha.0` | ||
The next time Release Please runs, it will use that override section as the | ||
commit message instead of the merged commit message. |
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
Oops, something went wrong.