Skip to content

Commit

Permalink
Update npm-publish-latest.yml
Browse files Browse the repository at this point in the history
This change
- splits the jobs into a build job and a publish job
- prevents the publish job from running on pull requests
  • Loading branch information
HeyItsBATMAN authored Mar 27, 2024
1 parent 6ba7620 commit d787f45
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions .github/workflows/npm-publish-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,43 @@ on:
types: [created]

jobs:
publish-latest:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 20

- 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@v3
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 run ci:build

publish:
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -46,10 +82,7 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: "Build"
run: pnpm run ci:build

- name: "Publish"
- name: Publish
run: pnpm run ci:publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

0 comments on commit d787f45

Please sign in to comment.