diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 75eb13a..80d2d4e 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -2,19 +2,34 @@ name: Publish to NPM on: release: types: [created] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 + - name: Setup Node uses: actions/setup-node@v2 with: node-version: '16' + + - name: Cache node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Build run: yarn install && yarn build + + - name: Set up .npmrc file for authentication + run: echo "registry=https://registry.npmjs.org/" >> .npmrc && echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc + - name: Publish package on NPM - run: npm publish + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}