Publish Beta NPM Packages #16
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
name: Publish Beta NPM Packages | |
on: | |
workflow_dispatch: | |
inputs: | |
packagePath: | |
description: 'Path to the package (e.g., action-block)' | |
required: true | |
betaVersion: | |
description: 'Beta version number (e.g., 1.0.1-beta.0)' | |
required: true | |
jobs: | |
publish-package: | |
runs-on: ubuntu-latest | |
if: >- | |
github.actor == 'JackLian' || github.actor == 'liujuping' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' # 或者您希望的任何版本 | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Change to Package Directory | |
run: cd packages/${{ github.event.inputs.packagePath }} | |
- name: Clear node_modules and lock file | |
run: | | |
rm -rf node_modules | |
rm -f package-lock.json # 或者 yarn.lock | |
npm cache clean --force | |
- name: Install specific version of react | |
run: npm install [email protected] | |
- name: Install Package Dependencies | |
run: npm install | |
- name: Build Package | |
run: npm run build | |
- name: Update Package Version | |
run: npm version ${{ github.event.inputs.betaVersion }} | |
- name: Publish Package | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 确保在您的 GitHub 仓库的 Secrets 中设置了 NPM_TOKEN |