11name : NPM Release
22
33# Consolidated workflow for all NPM releases:
4- # - Beta: On merge to main branch
5- # - Production: On GitHub release creation
4+ # - Beta: On v*-beta.* tags or beta GitHub releases
5+ # - Production: On stable GitHub release creation
66#
77# Version Management:
88# - Uses lerna version and publish commands with consistent patterns
@@ -12,21 +12,10 @@ name: NPM Release
1212
1313on :
1414 push :
15- branches :
16- - main # Triggers beta releases
17- paths-ignore :
18- - " **/*.md"
19- - " docs/**"
20- - " packages/docs/**"
21- - " .github/**/*.md"
22- - " LICENSE"
23- - " .gitignore"
24- - " .dockerignore"
25- - " **/*.example"
26- - " .vscode/**"
27- - " .devcontainer/**"
15+ tags :
16+ - " v*"
2817 release :
29- types : [created] # Triggers production releases
18+ types : [created]
3019 workflow_dispatch :
3120 inputs :
3221 release_type :
@@ -47,12 +36,13 @@ concurrency:
4736jobs :
4837 release :
4938 runs-on : ubuntu-latest
50- # Skip if commit message contains [skip ci], and keep prerelease tags
51- # out of the production/latest GitHub Release path .
39+ # Skip if commit message contains [skip ci]. Alpha releases are disabled;
40+ # beta prereleases are published from tags/releases with the beta dist-tag .
5241 if : >-
5342 ${{
5443 !contains(github.event.head_commit.message || '', '[skip ci]') &&
55- !(github.event_name == 'release' && contains(github.event.release.tag_name || '', '-'))
44+ !(github.event_name == 'release' && contains(github.event.release.tag_name || '', '-alpha')) &&
45+ !(github.ref_type == 'tag' && contains(github.ref_name || '', '-alpha'))
5646 }}
5747
5848 permissions :
@@ -153,21 +143,34 @@ jobs:
153143 id : release_type
154144 run : |
155145 if [[ "${{ github.event_name }}" == "release" ]]; then
156- echo "type=latest" >> $GITHUB_OUTPUT
157- echo "dist_tag=latest" >> $GITHUB_OUTPUT
158146 # Extract version from tag (remove 'v' prefix if present)
159147 VERSION="${{ github.event.release.tag_name }}"
160148 VERSION="${VERSION#v}"
149+ if [[ "${VERSION}" == *"-beta."* ]]; then
150+ echo "type=beta" >> $GITHUB_OUTPUT
151+ echo "dist_tag=beta" >> $GITHUB_OUTPUT
152+ else
153+ echo "type=latest" >> $GITHUB_OUTPUT
154+ echo "dist_tag=latest" >> $GITHUB_OUTPUT
155+ fi
156+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
157+ echo "is_release_event=true" >> $GITHUB_OUTPUT
158+ elif [[ "${{ github.ref_type }}" == "tag" ]]; then
159+ VERSION="${{ github.ref_name }}"
160+ VERSION="${VERSION#v}"
161+ if [[ "${VERSION}" == *"-beta."* ]]; then
162+ echo "type=beta" >> $GITHUB_OUTPUT
163+ echo "dist_tag=beta" >> $GITHUB_OUTPUT
164+ else
165+ echo "type=latest" >> $GITHUB_OUTPUT
166+ echo "dist_tag=latest" >> $GITHUB_OUTPUT
167+ fi
161168 echo "version=${VERSION}" >> $GITHUB_OUTPUT
162169 echo "is_release_event=true" >> $GITHUB_OUTPUT
163170 elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
164171 echo "type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
165172 echo "dist_tag=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
166173 echo "is_release_event=false" >> $GITHUB_OUTPUT
167- elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
168- echo "type=beta" >> $GITHUB_OUTPUT
169- echo "dist_tag=beta" >> $GITHUB_OUTPUT
170- echo "is_release_event=false" >> $GITHUB_OUTPUT
171174 fi
172175
173176 # Version Management
@@ -214,10 +217,10 @@ jobs:
214217 }
215218
216219 # Determine version strategy based on release type and current version
217- if [[ "${{ github.event_name }}" == "release " ]]; then
218- # Production release from GitHub release tag
220+ if [[ "${{ steps.release_type.outputs.is_release_event }}" == "true " ]]; then
221+ # Tagged release from git tag or GitHub release tag
219222 VERSION="${{ steps.release_type.outputs.version }}"
220- echo "📦 Production release: Setting exact version to ${VERSION}"
223+ echo "📦 Tagged release: Setting exact version to ${VERSION}"
221224 bunx lerna version ${VERSION} \
222225 --force-publish \
223226 --yes \
@@ -734,16 +737,16 @@ jobs:
734737
735738 # Compare versions and auto-advance if needed
736739 if [[ "$DEVELOP_BASE" < "$BASE_VERSION" ]]; then
737- # Develop is behind - update it to match production with alpha suffix
738- NEXT_ALPHA ="${BASE_VERSION}-alpha .0"
740+ # Develop is behind - update it to match production with beta suffix
741+ NEXT_BETA ="${BASE_VERSION}-beta .0"
739742
740- echo "Develop is behind: ${DEVELOP_VERSION} → ${NEXT_ALPHA }"
743+ echo "Develop is behind: ${DEVELOP_VERSION} → ${NEXT_BETA }"
741744
742745 # Create a branch for the sync (using release/ prefix for lerna)
743746 git checkout -b release/sync-develop-${BASE_VERSION} origin/develop
744747
745- # Update version to match production base with alpha suffix
746- bunx lerna version ${NEXT_ALPHA } \
748+ # Update version to match production base with beta suffix
749+ bunx lerna version ${NEXT_BETA } \
747750 --force-publish \
748751 --yes \
749752 --no-private \
@@ -756,12 +759,12 @@ jobs:
756759
757760 # Commit
758761 git add -A
759- git commit -m "chore: sync to v${NEXT_ALPHA } after v${BASE_VERSION} release [skip ci]" \
762+ git commit -m "chore: sync to v${NEXT_BETA } after v${BASE_VERSION} release [skip ci]" \
760763 -m "Automated version sync from production release"
761764
762765 # Push to develop
763766 if git push origin HEAD:develop; then
764- echo "✅ Successfully synced develop to ${NEXT_ALPHA }"
767+ echo "✅ Successfully synced develop to ${NEXT_BETA }"
765768 else
766769 echo "⚠️ Could not push to develop (may be protected or already updated)"
767770 fi
@@ -772,15 +775,15 @@ jobs:
772775 # Calculate next patch version
773776 IFS='.' read -r major minor patch <<< "$BASE_VERSION"
774777 NEXT_PATCH="${major}.${minor}.$((patch + 1))"
775- NEXT_ALPHA ="${NEXT_PATCH}-alpha .0"
778+ NEXT_BETA ="${NEXT_PATCH}-beta .0"
776779
777- echo "Auto-advancing: ${DEVELOP_VERSION} → ${NEXT_ALPHA }"
780+ echo "Auto-advancing: ${DEVELOP_VERSION} → ${NEXT_BETA }"
778781
779782 # Create a branch for the sync (using release/ prefix for lerna)
780783 git checkout -b release/sync-develop-${BASE_VERSION} origin/develop
781784
782- # Update version to next patch with alpha suffix
783- bunx lerna version ${NEXT_ALPHA } \
785+ # Update version to next patch with beta suffix
786+ bunx lerna version ${NEXT_BETA } \
784787 --force-publish \
785788 --yes \
786789 --no-private \
@@ -793,12 +796,12 @@ jobs:
793796
794797 # Commit
795798 git add -A
796- git commit -m "chore: bump to v${NEXT_ALPHA } after v${BASE_VERSION} release [skip ci]" \
799+ git commit -m "chore: bump to v${NEXT_BETA } after v${BASE_VERSION} release [skip ci]" \
797800 -m "Automated patch version bump from production release"
798801
799802 # Push to develop
800803 if git push origin HEAD:develop; then
801- echo "✅ Successfully auto-advanced develop to ${NEXT_ALPHA }"
804+ echo "✅ Successfully auto-advanced develop to ${NEXT_BETA }"
802805 else
803806 echo "⚠️ Could not push to develop (may be protected or already updated)"
804807 fi
@@ -837,7 +840,7 @@ jobs:
837840
838841 if [[ -z "${NEW_DEVELOP_BASE}" ]]; then
839842 git checkout origin/develop -- lerna.json 2>/dev/null || true
840- NEW_DEVELOP_VERSION=$(node -p "require('./lerna.json').version" 2>/dev/null || echo "${BASE_VERSION}-alpha .0")
843+ NEW_DEVELOP_VERSION=$(node -p "require('./lerna.json').version" 2>/dev/null || echo "${BASE_VERSION}-beta .0")
841844 NEW_DEVELOP_BASE=$(echo "$NEW_DEVELOP_VERSION" | sed 's/-.*$//')
842845 git checkout HEAD -- lerna.json
843846 fi
0 commit comments