Skip to content

Commit 0e72e68

Browse files
authored
Npm (#45)
1 parent de54773 commit 0e72e68

2 files changed

Lines changed: 64 additions & 50 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ on:
44
push:
55
branches:
66
- master
7-
release:
8-
types: [ published ]
97
pull_request:
108
branches:
119
- '**'
10+
workflow_call:
1211

1312
env:
1413
PRIMARY_NODE_VERSION: 24.x
@@ -78,51 +77,3 @@ jobs:
7877
- name: Run unit tests
7978
if: "!(matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS)"
8079
run: yarn test:unit
81-
82-
publish_version:
83-
name: Publish
84-
runs-on: ${{ matrix.os }}
85-
strategy:
86-
matrix:
87-
os: [ ubuntu-latest ]
88-
node-version: [ 24.x ]
89-
needs: [ test ]
90-
if: github.event_name == 'release' && github.event.action == 'published'
91-
steps:
92-
93-
- name: Checkout
94-
uses: actions/checkout@v5
95-
96-
- name: fetch
97-
run: |
98-
git fetch --prune --unshallow
99-
100-
- name: Use Node.js ${{ matrix.node-version }}
101-
uses: actions/setup-node@v6
102-
with:
103-
node-version: ${{ matrix.node-version }}
104-
registry-url: ${{ env.REGISTRY }}
105-
106-
- name: Get yarn cache directory
107-
id: yarn-cache-dir
108-
run: |
109-
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
110-
111-
- uses: actions/cache@v4
112-
id: yarn-cache
113-
with:
114-
path: ${{ steps.yarn-cache-dir.outputs.dir }}
115-
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
116-
restore-keys: |
117-
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
118-
119-
- name: Install dependencies and build
120-
run: |
121-
yarn install --ignore-engines
122-
yarn build
123-
124-
- name: Publish
125-
uses: JS-DevTools/npm-publish@v1
126-
with:
127-
token: ${{ secrets.NPM_AUTH_TOKEN }}
128-
registry: ${{ env.REGISTRY }}

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
permissions:
8+
id-token: write # Required for OIDC authentication
9+
contents: read # Allows checking out the repository contents
10+
11+
env:
12+
REGISTRY: https://registry.npmjs.org/
13+
14+
jobs:
15+
test:
16+
name: Run tests before publish
17+
uses: ./.github/workflows/ci.yml
18+
secrets: inherit
19+
20+
publish_version:
21+
name: Publish to NPM
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
node-version: [ 24.x ]
26+
needs: [ test ]
27+
steps:
28+
29+
- name: Checkout
30+
uses: actions/checkout@v5
31+
32+
- name: fetch
33+
run: |
34+
git fetch --prune --unshallow
35+
36+
- name: Use Node.js ${{ matrix.node-version }}
37+
uses: actions/setup-node@v6
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
registry-url: ${{ env.REGISTRY }}
41+
42+
- name: Get yarn cache directory
43+
id: yarn-cache-dir
44+
run: |
45+
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
46+
47+
- uses: actions/cache@v4
48+
id: yarn-cache
49+
with:
50+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
51+
key: ubuntu-latest-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
52+
restore-keys: |
53+
ubuntu-latest-${{ matrix.node-version }}-yarn-
54+
55+
- name: Install dependencies and build
56+
run: |
57+
yarn install --ignore-engines
58+
yarn build
59+
60+
- name: Install dependencies and build
61+
run: |
62+
yarn install --ignore-engines
63+
yarn publish

0 commit comments

Comments
 (0)