Skip to content

🐎 ci(package.json): 修改库名称 #10

🐎 ci(package.json): 修改库名称

🐎 ci(package.json): 修改库名称 #10

Workflow file for this run

name: Build and Publish
on:
push:
branches: [ main ]
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
scope: '@marherb-work'
- name: Check package.json version change
id: check_version
run: |
VERSION_IN_GIT=$(git diff HEAD~ -- package.json | grep -oP '(?<="version": ")[^"]*' || echo "not_found")
CURRENT_VERSION=$(node -p "require('./package.json').version")
if [ "$VERSION_IN_GIT" == "$CURRENT_VERSION" ] || [ "$VERSION_IN_GIT" == "not_found" ]; then
echo "Version has not changed or unable to find previous version info."
echo "version_changed=false" >> $GITHUB_ENV
else
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_ENV
fi
- name: Install dependencies
if: env.version_changed == 'true'
run: yarn install
- name: Build package
if: env.version_changed == 'true'
run: yarn build
- name: Publish to NPM
if: env.version_changed == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}