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 }}