From 860b5f453531e989725f517c7e8b5352d740f3d4 Mon Sep 17 00:00:00 2001 From: Alexander Gribochkin Date: Mon, 17 Jun 2024 20:52:13 +0300 Subject: [PATCH] chore: add action to publish --- .github/workflows/publish.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd512de..7ac92fb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,15 +5,30 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@v3 # Setup .npmrc file to publish to npm - uses: actions/setup-node@v3 with: - node-version: "16.x" + node-version: "20.x" registry-url: "https://registry.npmjs.org" + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + + - uses: actions/cache@v3 + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - run: npm ci - run: npm test - - run: npm publish + - run: npm publish --provenance --access public env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file