ci: 修复 npm-publish 工作流 yarn install 缺少 NODE_AUTH_TOKEN #96
This file contains hidden or 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: npm-publish | |
| on: | |
| push: | |
| paths: | |
| - '.github/NPM_PUBLISH_VERSION.md' | |
| branches: | |
| - master # Change this to your default branch | |
| jobs: | |
| npm-publish: | |
| name: npm-publish | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'node-pinus/pinus' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@master | |
| - name: Set up Node.js | |
| uses: actions/setup-node@master | |
| with: | |
| node-version: 18 | |
| registry-url: https://registry.npmjs.org/ | |
| - run: git remote set-url origin https://node-pinus:${{ secrets.GITHUB_TOKEN }}@github.com/node-pinus/pinus.git | |
| - run: git checkout origin/master -B master | |
| - run: git config --global user.email "mybios@qq.com" | |
| - run: git config --global user.name "mybios" | |
| - run: git config --global credential.helper store | |
| - run: yarn | |
| - run: yarn build | |
| - run: git checkout yarn.lock | |
| - run: yarn run version `head -n +1 .github/NPM_PUBLISH_VERSION.md` --no-push --force-publish --yes | |
| - run: yarn run publish from-package --no-push --no-git-reset --yes --force-publish --registry https://registry.npmjs.org/ | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | |
| - run: git status | |
| - run: git push origin --tags | |
| - run: git push origin master | |
| env: # More info about the environment variables in the README | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| # setup-node 生成的 .npmrc 引用 ${NODE_AUTH_TOKEN},yarn install 步骤也需要该变量存在 | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |