Skip to content

Commit

Permalink
ci: use semantic-release for publishing npm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Mar 29, 2023
1 parent 88e4634 commit 74f408e
Show file tree
Hide file tree
Showing 4 changed files with 3,500 additions and 221 deletions.
54 changes: 13 additions & 41 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ permissions:
contents: read

jobs:
build:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3

- name: Use Node.js 18
- name: Use LTS Node.js
uses: actions/setup-node@a4fcaaf314b117a40d694a35ee36461f8ff3c6e6
with:
node-version: 18
cache: yarn
cache-dependency-path: yarn.lock
node-version: lts/*
ache-dependency-path: yarn.lock

- name: Install
run: yarn install
Expand All @@ -34,42 +38,10 @@ jobs:
- name: Test
run: yarn test

publish-github:
needs: build
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3

- name: Use Node.js 18
uses: actions/setup-node@a4fcaaf314b117a40d694a35ee36461f8ff3c6e6
with:
node-version: 18
registry-url: https://npm.pkg.github.com/

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3

- name: Use Node.js 18
uses: actions/setup-node@a4fcaaf314b117a40d694a35ee36461f8ff3c6e6
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- run: npm publish
- name: Semantic Release - NPM & GITHUB
run: npx semantic-release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

...
6 changes: 6 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

branches:
- main

...
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@vitest/coverage-c8": "^0.29.7",
"eslint": "8.37.0",
"prettier": "2.8.7",
"semantic-release": "^21.0.0",
"typescript": "5.0.2",
"vitest": "^0.29.7"
},
Expand Down
Loading

0 comments on commit 74f408e

Please sign in to comment.