Skip to content

v1.1.3

v1.1.3 #23

Workflow file for this run

name: NPM Publish
on:
release:
types: [created]
push:
branches:
- master
- 'v*'
paths:
- '.github/workflows/npm-publish.yml' # 添加对自身文件的监听
workflow_dispatch:
inputs:
version:
description: 'Version to publish (eg: 1.0.0)'
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
# 在 CI 环境中使用 npm 官方源
- name: Configure npm for CI
run: |
echo "registry=https://registry.npmjs.org/" > .npmrc
echo "strict-ssl=true" >> .npmrc
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Update version
if: github.event_name == 'workflow_dispatch'
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# 工作流完成后恢复原始 .npmrc
- name: Restore original .npmrc
run: |
if [ -f .npmrc.backup ]; then
mv .npmrc.backup .npmrc
fi