From f3aafc428e2b63f05f79d3020b72a379079986d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Sat, 2 Dec 2023 16:45:51 +0100 Subject: [PATCH] Github actions to publish package --- .github/workflows/publish.yml | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1eb12d8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,43 @@ +name: Publish package +on: + push: + branches: [ 'main' ] + tags: [ 'v*' ] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + + - uses: pnpm/action-setup@v2 + with: + run_install: true + + - name: make an explicitly tagged release version + if: ${{ github.ref_type == 'tag' }} + run: | + npm version --no-git-tag-version from-git + echo "NPM_PUBLISH_TAG=latest" >> $GITHUB_ENV + + - name: rolling versioned dev package from main + if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }} + run: | + npm version --no-git-tag-version `git describe --tags --long | sed s/^v//` + echo "NPM_PUBLISH_TAG=dev" >> $GITHUB_ENV + + - run: pnpm dist + + - run: pnpm publish --tag "${{ env.NPM_PUBLISH_TAG }}" + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}