Skip to content

Commit

Permalink
add publish as separate CI job
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj authored and rychlis committed Apr 9, 2024
1 parent 72c4503 commit f2d81a0
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI check
on:
push:
branches: [main]
tags:
- "*"
pull_request:
branches: [main]

Expand Down Expand Up @@ -50,12 +52,46 @@ jobs:
LANGTAIL_API_KEY: ${{secrets.LANGTAIL_API_KEY}}
run: pnpm test

- name: run build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: pnpm build
publish:
runs-on: ubuntu-latest
name: Publish to NPM
needs: build
if: github.event_name == 'create' && github.event.ref_type == 'tag'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: current

- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies and build
run: |
pnpm install
pnpm build
- uses: JS-DevTools/npm-publish@v3
name: Publish package
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
token: ${{ secrets.NPM_TOKEN }}

0 comments on commit f2d81a0

Please sign in to comment.