Skip to content

Commit 155b0e1

Browse files
committed
chore: add a publish workflow on tag
1 parent d97d3be commit 155b0e1

File tree

3 files changed

+112
-50
lines changed

3 files changed

+112
-50
lines changed

.github/workflows/checks.yml

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,16 @@
1+
---
12
name: CI
23

3-
on: [push, pull_request]
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
47

5-
jobs:
6-
lint:
7-
runs-on: ubuntu-latest
8-
9-
steps:
10-
- uses: actions/checkout@v5
11-
12-
- name: Setup Node.js
13-
uses: actions/setup-node@v6
14-
with:
15-
node-version: 24
16-
17-
- name: Install dependencies
18-
run: npm ci
19-
20-
- name: Lint
21-
run: npm run lint
22-
23-
test:
24-
runs-on: ubuntu-latest
25-
26-
steps:
27-
- uses: actions/checkout@v5
8+
on:
9+
push:
10+
branches: ['*']
11+
pull_request:
2812

29-
- name: Setup Node.js
30-
uses: actions/setup-node@v6
31-
with:
32-
node-version: 21
33-
34-
- name: Install dependencies
35-
run: npm ci
36-
37-
- name: Test
38-
run: npm run test
39-
40-
build:
41-
runs-on: ubuntu-latest
42-
43-
steps:
44-
- uses: actions/checkout@v5
45-
46-
- name: Setup Node.js
47-
uses: actions/setup-node@v6
48-
with:
49-
node-version: 21
50-
51-
- name: Install dependencies
52-
run: npm ci
13+
jobs:
14+
ci:
15+
uses: ./.github/workflows/reusable-ci.yml
5316

54-
- name: Build
55-
run: npm run build

.github/workflows/on-tag.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to npm
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
env:
8+
NODE_VERSION: 24
9+
10+
on:
11+
push:
12+
tags: ['*']
13+
14+
permissions:
15+
id-token: write
16+
contents: read
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v5
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v6
26+
with:
27+
node-version: ${{ env.NODE_VERSION }}
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Update npm
31+
run: npm install -g npm@latest
32+
33+
- run: npm ci
34+
35+
- run: npm run lint
36+
37+
- run: npm run test
38+
39+
- run: npm run build
40+
41+
- name: Update version
42+
run: npm version $GITHUB_REF_NAME --no-git-tag-version
43+
44+
- name: Publish to npm
45+
run: |
46+
VERSION=$(node -p "require('./package.json').version")
47+
if [[ $VERSION == *-* ]]; then
48+
TAG="next"
49+
else
50+
TAG="latest"
51+
fi
52+
npm publish --tag $TAG

.github/workflows/reusable-ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Reusable CI
2+
3+
env:
4+
NODE_VERSION: 24
5+
6+
on: workflow_call
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v6
16+
with:
17+
node-version: ${{ env.NODE_VERSION }}
18+
19+
- run: npm ci
20+
21+
- run: npm run lint
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v5
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
33+
- run: npm ci
34+
35+
- run: npm run test
36+
37+
build:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v5
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v6
44+
with:
45+
node-version: ${{ env.NODE_VERSION }}
46+
47+
- run: npm ci
48+
49+
- run: npm run build

0 commit comments

Comments
 (0)