From 7c876c9bd649e0313cc9001c36525ef816e13a1a Mon Sep 17 00:00:00 2001 From: Leonardo Ferreira Lima <80768424@redecorp.br> Date: Wed, 27 Sep 2023 12:52:41 -0300 Subject: [PATCH] ci: add npm publish action fix #12 --- .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ package.json | 2 +- tsconfig.publish.json | 5 ++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml create mode 100644 tsconfig.publish.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..57ea9d4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 }} diff --git a/package.json b/package.json index 6f6298e..9dd7dfd 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "scripts": { "prepare": "husky install", - "build": "tsc -p .", + "build": "tsc -p ./tsconfig.publish.json", "lint": "eslint .", "format": "prettier --write .", "commit": "cz", diff --git a/tsconfig.publish.json b/tsconfig.publish.json new file mode 100644 index 0000000..0670ee0 --- /dev/null +++ b/tsconfig.publish.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["src"], + "exclude": ["test", "**/*.spec.ts"] +}