Skip to content

Commit 3181826

Browse files
chore(ci): set up publish workflow (#53)
Resolves #50 .
1 parent 02b66bc commit 3181826

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
branches:
44
- main
55
pull_request: {}
6+
workflow_call: {}
67

78
concurrency:
89
group: '${{ github.workflow }} - ${{ github.head_ref || github.ref }}'
@@ -14,7 +15,7 @@ permissions:
1415

1516
jobs:
1617

17-
build:
18+
check:
1819
strategy:
1920
matrix:
2021
node-version: [18, 20]
@@ -31,8 +32,7 @@ jobs:
3132
node-version: ${{ matrix.node-version }}
3233
- name: Setup LCOV
3334
uses: hrishikesh-kadam/setup-lcov@v1
34-
35-
- name: Enable Yarn
35+
- name: Setup Yarn
3636
run: corepack enable
3737

3838
- name: Install Packages
@@ -48,7 +48,7 @@ jobs:
4848
run: yarn coverage
4949

5050
- name: Report Coverage
51-
if: ${{ matrix.node-version == 20 }}
51+
if: ${{ matrix.node-version == 20 && github.event_name == 'pull_request' }}
5252
uses: zgosalvez/github-actions-report-lcov@v4
5353
with:
5454
coverage-files: coverage/lcov.info

.github/workflows/publish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
on:
2+
workflow_dispatch: {}
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
check:
9+
uses: ./.github/workflows/ci.yml
10+
secrets: inherit
11+
12+
publish:
13+
needs: check
14+
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
id-token: write
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: lts/*
29+
registry-url: 'https://registry.npmjs.com'
30+
check-latest: true
31+
- name: Setup Yarn
32+
run: corepack enable
33+
34+
- name: Install Packages
35+
run: yarn install
36+
37+
- name: Build
38+
run: yarn build
39+
40+
- name: Publish
41+
run: |
42+
npm install -g npm@latest
43+
npm publish --provenance
44+
env:
45+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"lint-docs": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"",
4848
"lint-eslint-docs": "yarn build && eslint-doc-generator --check",
4949
"docs": "eslint-doc-generator",
50-
"release": "bumpp && yarn run build",
50+
"release": "bumpp && echo \"Create a new release in GitHub to trigger the publish workflow.\"",
5151
"test": "vitest",
5252
"coverage": "vitest run --coverage",
5353
"typecheck": "tsc --noEmit"

0 commit comments

Comments
 (0)