Skip to content

Commit

Permalink
Merge pull request #72 from ERC725Alliance/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
frozeman authored Jan 5, 2022
2 parents b7f870e + a344203 commit 8a518eb
Show file tree
Hide file tree
Showing 23 changed files with 916 additions and 731 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Bump version
on:
workflow_dispatch:
inputs:
arguments:
description: 'standard-release arguments'
required: false
default: ''

jobs:
bump-version:
name: Bump version
runs-on: ubuntu-latest
steps:
- name: Ensure develop branch
if: github.ref != 'refs/heads/develop'
run: |-
echo "Not running on develop - exit"
exit 1
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: ⚙️ Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'

- name: 🧰 Install
run: npm ci

- name: ⬆️ Bump package version
run: |-
git config --global user.email "[email protected]"
git config --global user.name "Release Bot"
npm run release -- ${{ github.event.inputs.arguments }}
- name: 📝 Set Version
run: |-
APP_VERSION="v$(node -pe "require('./package.json').version")"
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
branch: bump/${{ env.APP_VERSION }}
base: develop
delete-branch: true
title: ':arrow_up: Bump to ${{ env.APP_VERSION }}'
body: |
Bump to version: ${{ env.APP_VERSION }}
labels: |
automated pr
- name: Checkout to PR branch
uses: actions/checkout@v2
with:
ref: bump/${{ env.APP_VERSION }}

# We purposely not push the tag
# The tag will be added when develop is merged into main
- run: git push

- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/publish.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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

on:
workflow_dispatch:
push:
branches:
- 'main'

jobs:
release:
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
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: 🎯 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
with:
state: closed

- name: Add PR body to Release Notes
if: env.SHOULD_RELEASE == 'true'
run: |-
echo ${{ steps.findPR.outputs.body }}|cat - RELEASENOTES.md > /tmp/out && mv /tmp/out RELEASENOTES.md
- 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: 📦 Publish to NPM
if: env.SHOULD_RELEASE == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
This project uses Conventional Commits to generate release notes and to determine versioning. Commit messages should adhere to this standard and be of the form:

```bash
$ git commit -m "feat: Add new feature x"
$ git commit -m "fix: Fix bug in feature x"
$ git commit -m "docs: Add documentation for feature x"
$ git commit -m "test: Add test suite for feature x"
git commit -m "feat: Add new feature x"
git commit -m "fix: Fix bug in feature x"
git commit -m "docs: Add documentation for feature x"
git commit -m "test: Add test suite for feature x"
```

Further details on `conventional commits` can be found here: https://www.conventionalcommits.org/en/v1.0.0/

## Building

```shell script
$ npm run build
npm run build
```

This will build the library into `/build`

## Testing

```shell script
$ npm test
npm test
```

Will build and then publish the package to npm.
Expand Down
25 changes: 18 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
# Release Process

Releases are published to NPM when a [GitHub release](https://github.com/ERC725Alliance/erc725.js/releases/new) is created.
Releases are published to NPM when `develop` is merged into `main` AND when the merged code contains a version bump in the `package.json`.

## Create and publish a new release:

1. Checkout to a new release branch.
2. Bump version with [standard-version](https://github.com/conventional-changelog/standard-version):
### Bump version

You can manually trigger the [Bump version](https://github.com/ERC725Alliance/erc725.js/actions/workflows/bump-version.yml) workflow from the `develop` branch.

To bump locally:

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.

```bash
npm run release
```

3. Then push the changes to origin, **with tags** and open a PR.
3. Push the changes to origin, **WITH TAGS**.

```bash
git push --follow-tags origin
```

4. Merge the PR to main.
5. Create a new [GitHub release](https://github.com/ERC725Alliance/erc725.js/releases/new) with the tag you just created.
6. The CI will build and publish to npm.
4. Open a PR from your release branch to `develop` and merge it.

### Release

- Merge `develop` into `main` through a PR.
- The CI will create a GitHub release and publish to NPM.

If it fails, you can manually trigger the workflow from the [Actions](https://github.com/ERC725Alliance/erc725.js/actions/workflows/release.yml) tab.

## Specific Version Increases

Expand Down
Loading

0 comments on commit 8a518eb

Please sign in to comment.