Skip to content

安装 pnpm

安装 pnpm #3

Workflow file for this run

name: Publish npm package
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm i
- name: Run tests
run: pnpm test
- name: Check if version changed
id: version_check
run: |
git fetch origin main
PREVIOUS_VERSION=$(git show origin/main:package.json | jq -r .version)
CURRENT_VERSION=$(jq -r .version package.json)
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if [ "$PREVIOUS_VERSION" == "$CURRENT_VERSION" ]; then
echo "Version has not changed. Exiting."
exit 0
fi
- name: Publish to npm
if: ${{ steps.version_check.outputs.current_version != steps.version_check.outputs.previous_version }}
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}