Skip to content

Commit

Permalink
Merge pull request #36 from leoferreiralima/ci/publish-to-npm
Browse files Browse the repository at this point in the history
ci: add npm publish action
  • Loading branch information
leoferreiralima committed Sep 27, 2023
2 parents 25e9c32 + 7c876c9 commit 83996d5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish to NPM
on:
release:
types: [released]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
run_install: false
version: 8

- 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 build

- name: Publish package on NPM 📦
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"prepare": "husky install",
"build": "tsc -p .",
"build": "tsc -p ./tsconfig.publish.json",
"lint": "eslint .",
"format": "prettier --write .",
"commit": "cz",
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.publish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": ["test", "**/*.spec.ts"]
}

0 comments on commit 83996d5

Please sign in to comment.