diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f1ffd33..94fa689 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,20 +5,49 @@ name: NPM on: push: - branches: [ master ] + branches: [master] jobs: publish-npm: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 with: node-version: 20 - registry-url: https://registry.npmjs.org/ - - run: rm -rf node_modules && pnpm install --frozen-lockfile - - run: pnpm build - - run: pnpm test - - run: npm publish + + - uses: pnpm/action-setup@v3 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Test + run: pnpm test + + - name: Publish to NPM + run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}