Skip to content

Commit

Permalink
feat(engineering): add semantic-release
Browse files Browse the repository at this point in the history
closes #541
  • Loading branch information
joaomoreno committed Nov 2, 2021
1 parent f58e0c4 commit b0fdd41
Show file tree
Hide file tree
Showing 3 changed files with 4,450 additions and 141 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
Expand All @@ -25,19 +27,19 @@ jobs:
- run: npm run build
- run: npm test

publish:
release:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- run: npm install
- run: npm run build
- run: npm publish
- run: npx semantic-release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading

3 comments on commit b0fdd41

@felipecrs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaomoreno Wow. Very nice! But you may like to prefix changes like this with ci instead of feat to avoid them triggering a new release (unless you did this on purpose to test the first release with semantic-release).

@joaomoreno
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaomoreno Wow. Very nice! But you may like to prefix changes like this with ci instead of feat to avoid them triggering a new release (unless you did this on purpose to test the first release with semantic-release).

I did. 😉

@felipecrs
Copy link
Contributor

@felipecrs felipecrs commented on b0fdd41 Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok! :D

BTW, here is an example on how the semantic-release can be configured to achieve some additional things (just in case you want, so you can take as inspiration):

https://github.com/felipecrs/megatar/blob/dbb176d8e2039083e32aae392a559f2838fecce3/release.config.js

Like:

  1. Publish refactor, perf and build(deps) as patch versions and add them to the changelog
  2. Write a footer in the GitHub Release with a link to npm.js (https://github.com/felipecrs/megatar/releases/tag/v1.2.1)
  3. Write a CHANGELOG.md in the root of the repository with the changes and commit it automatically (felipecrs/megatar@88c7a85)
  4. Upload the npm's .tgz to GitHub Releases too instead of only to npm.js (https://github.com/felipecrs/megatar/releases/download/v1.2.1/megatar-1.2.1.tgz)

Some additional changes would be required though... like creating a GitHub token with privilege to push directly to main (Github Actions' default token does not come with this) and addind conventional-changelog-conventionalcommits as devDependencies.

Please sign in to comment.