Skip to content

Commit

Permalink
feat: build and publish by github action
Browse files Browse the repository at this point in the history
  • Loading branch information
TzuHuanTai committed Jan 28, 2025
1 parent 3d45d48 commit 5b2c49f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "picamera.js",
"version": "1.0.4",
"main": "dist/picamera.js",
"types": "build/index.d.ts",
"module": "dist/picamera.esm.js",
Expand Down

0 comments on commit 5b2c49f

Please sign in to comment.