From 818bb29213a40d4e28c0b64d9449f78c7313715e Mon Sep 17 00:00:00 2001 From: Mikalai Silivonik Date: Wed, 14 Aug 2024 10:36:54 -0400 Subject: [PATCH] Improved Publishing Process (#2) **Pre-release**: If the Git tag matches `v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+` (e.g., `v1.0.0-alpha.1`), the version is taken from the tag, and the package is published as a pre-release. **Stable Release**: If the Git tag matches `v[0-9]+.[0-9]+.[0-9]+` (e.g., `v1.0.0`), the version is taken from `package.json` and published as the latest stable version. --- .github/workflows/npm.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm.yaml b/.github/workflows/npm.yaml index acd17d7..30d37bc 100644 --- a/.github/workflows/npm.yaml +++ b/.github/workflows/npm.yaml @@ -3,7 +3,8 @@ name: Publish to npm on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+' jobs: build: @@ -18,6 +19,19 @@ jobs: with: node-version: 20.x cache: 'npm' + registry-url: 'https://registry.npmjs.org/' + + - name: Determine pre-release tag + id: release-tag + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + echo "Detected tag: $TAG_NAME" + if [[ "$TAG_NAME" == *-alpha.* ]]; then + echo "tag=alpha" >> $GITHUB_ENV + npm version --no-git-tag-version $TAG_NAME + else + echo "tag=latest" >> $GITHUB_ENV + fi - name: Install dependencies run: npm ci @@ -29,6 +43,6 @@ jobs: run: npm run compile - name: Publish - run: npm publish --access public + run: npm publish --access public --tag ${{ env.tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}