-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build and publish by github action
- Loading branch information
1 parent
3d45d48
commit 5b2c49f
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish to npm | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
publish: | ||
name: Publish Package | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
|
||
- name: Extract tag version | ||
id: extract_version | ||
run: echo "TAG_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV | ||
|
||
- name: Insert version into package.json | ||
run: | | ||
node -e " | ||
const fs = require('fs'); | ||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8')); | ||
packageJson.version = process.env.TAG_VERSION; | ||
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2)); | ||
console.log('Updated version to', process.env.TAG_VERSION); | ||
" | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build the package | ||
run: npm run build | ||
|
||
- name: Publish to npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters