Skip to content

Commit 1164f42

Browse files
committed
Add ci
1 parent f44f61c commit 1164f42

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish NPM Package to GitHub Packages and npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- ci
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Build Plugin
26+
run: npm run build
27+
28+
- name: Authenticate with GitHub Packages
29+
run: |
30+
echo "//npm.pkg.github.com/:_authToken=${{secrets.GITHUB_TOKEN}}" > ~/.npmrc
31+
echo "registry=https://npm.pkg.github.com" >> ~/.npmrc
32+
33+
- name: Test publish to GitHub Packages
34+
if: github.ref == 'refs/heads/ci'
35+
run: |
36+
echo "Testing publish to GitHub Packages..."
37+
npm publish --dry-run --registry=https://npm.pkg.github.com
38+
39+
- name: Publish to GitHub Packages
40+
if: github.ref == 'refs/heads/main'
41+
run: npm publish --registry=https://npm.pkg.github.com
42+
43+
- name: Authenticate with npm
44+
run: |
45+
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
46+
47+
- name: Test publish to npm registry
48+
if: github.ref == 'refs/heads/ci'
49+
run: |
50+
echo "Testing publish to npm registry..."
51+
npm publish --dry-run --registry=https://registry.npmjs.org
52+
53+
- name: Publish to npm registry
54+
if: github.ref == 'refs/heads/main'
55+
run: npm publish --registry=https://registry.npmjs.org

0 commit comments

Comments
 (0)