From 5dcb7339a62ea10c2c960000cfbc3c5f9e570482 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Thu, 29 Jun 2023 10:42:25 +0200 Subject: [PATCH] Add GitHub Actions workflow to publish to NPM --- .github/workflows/ci.yml | 3 -- .github/workflows/publish.yml | 52 +++++++++++++++++++++++++++++++++++ package.json | 4 +++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 924744812..0b6dd347b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean install of node dependencies and run tests -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: CI on: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..3c6f2c0a3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish + +on: + release: + types: [published] + +permissions: + id-token: write + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache .yarn/cache + uses: actions/cache@v3 + env: + cache-name: yarn-cache + with: + path: .yarn/cache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }} + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn --immutable + env: + HUSKY: 0 + + - name: Publish with latest tag + if: github.event.release.prelease == false + run: yarn npm publish --tag latest + env: + YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish with next tag + if: github.event.release.prelease == true + run: yarn npm publish --tag next + env: + YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 74a93b3e6..dcf644013 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,10 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" }, + "publishConfig": { + "access": "public", + "provenance": true + }, "files": [ "dist", "src"