Skip to content

Commit 3bb7bb4

Browse files
authored
Merge pull request #4 from nbaglivo/cicd-publish
(cicd): publish on merge to main
2 parents 8cc7c8d + 0ffeb33 commit 3bb7bb4

3 files changed

Lines changed: 78 additions & 15 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup pnpm
2+
description: pnpm 9, Node (configurable), and frozen lockfile install — run actions/checkout before this action
3+
4+
inputs:
5+
node-version:
6+
description: Node.js version (default 22; Trusted Publishing on npm requires >= 22.14.0)
7+
required: false
8+
default: '22'
9+
registry-url:
10+
description: Optional npm registry URL (e.g. https://registry.npmjs.org for publishing)
11+
required: false
12+
default: ''
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- uses: pnpm/action-setup@v4
18+
with:
19+
version: 9
20+
21+
- name: Setup Node.js
22+
if: ${{ inputs.registry-url == '' }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ inputs.node-version }}
26+
cache: pnpm
27+
28+
- name: Setup Node.js (npm registry)
29+
if: ${{ inputs.registry-url != '' }}
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ inputs.node-version }}
33+
cache: pnpm
34+
registry-url: ${{ inputs.registry-url }}
35+
36+
- name: Install dependencies
37+
shell: bash
38+
run: pnpm install --frozen-lockfile

.github/workflows/ci.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,10 @@ jobs:
99
name: Test
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
12+
- uses: actions/checkout@v4
1413

15-
- name: Setup pnpm
16-
uses: pnpm/action-setup@v4
17-
with:
18-
version: 9
19-
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: '20'
24-
cache: 'pnpm'
25-
26-
- name: Install dependencies
27-
run: pnpm install --frozen-lockfile
14+
- name: Setup workspace
15+
uses: ./.github/actions/setup-pnpm
2816

2917
- name: Run tests
3018
run: pnpm test

.github/workflows/publish-npm.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
concurrency:
13+
group: npm-publish-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
name: Publish to npm
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup workspace
24+
uses: ./.github/actions/setup-pnpm
25+
with:
26+
registry-url: https://registry.npmjs.org
27+
28+
- name: Run tests
29+
run: pnpm test
30+
31+
- name: Build
32+
run: pnpm build
33+
34+
- name: Publish to npm
35+
run: |
36+
npm install -g npm@^11.5.1
37+
pnpm publish --no-git-checks

0 commit comments

Comments
 (0)