Skip to content

Commit 381fdba

Browse files
committed
ci: replace ci.yaml with main and ci-cd workflows
1 parent c22b9c9 commit 381fdba

2 files changed

Lines changed: 33 additions & 24 deletions

File tree

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
1-
name: Publish to npm
1+
name: CI and Publish
2+
23
on:
34
push:
5+
branches:
6+
- master
47
tags:
58
- '*'
9+
pull_request:
10+
branches:
11+
- master
612

713
permissions:
8-
id-token: write # Required for OIDC (https://docs.npmjs.com/trusted-publishers)
14+
id-token: write # Required for OIDC (https://docs.npmjs.com/trusted-publishers)
915
contents: read
1016

1117
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '24'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run tests
34+
run: npm run test
35+
1236
publish:
1337
runs-on: ubuntu-latest
38+
needs: test
39+
if: startsWith(github.ref, 'refs/tags/')
1440

1541
steps:
1642
- name: Checkout code
@@ -30,7 +56,7 @@ jobs:
3056
run: |
3157
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
3258
tags_name="${{ github.ref }}"
33-
tags_name="${tags_name#refs/tags/}" # Remove the "refs/tags/" prefix
59+
tags_name="${tags_name#refs/tags/}"
3460
if [[ $tags_name == *"beta"* ]]; then
3561
echo "is_beta=true" >> $GITHUB_OUTPUT
3662
else
@@ -41,7 +67,11 @@ jobs:
4167
- name: Publish to npm (beta)
4268
if: steps.is_tag_beta.outputs.is_beta == 'true'
4369
run: npm publish --tag beta
70+
env:
71+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4472

4573
- name: Publish to npm
4674
if: steps.is_tag_beta.outputs.is_beta == 'false'
4775
run: npm publish
76+
env:
77+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/ci.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)