Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions .github/workflows/publish-js-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#
# 2. PRE-RELEASE (manual, workflow_dispatch):
# - Manually triggered via GitHub Actions UI
# - Choose pre-release type (beta/alpha/rc) and version
# - Publishes with appropriate dist-tag (beta/alpha/next)
# - Automatically appends "rc.{run_number}" to current package.json version
# - Publishes with "rc" dist-tag
# - Does NOT require updating package.json in the repository
#

Expand All @@ -20,20 +20,7 @@ on:
push:
tags:
- "js-sdk-v*.*.*" # Trigger on version tags like js-sdk-v0.1.0, js-sdk-v1.2.3, etc.
workflow_dispatch:
inputs:
prerelease_type:
description: "Pre-release type (determines npm dist-tag)"
required: true
type: choice
options:
- beta
- alpha
- rc
version:
description: "Version to publish (e.g., 1.2.3-beta.1)"
required: true
type: string
workflow_dispatch: # Trigger pre-release manually

jobs:
validate:
Expand Down Expand Up @@ -98,7 +85,10 @@ jobs:
if: github.event_name == 'workflow_dispatch'
working-directory: js
run: |
./scripts/publish-prerelease.sh "${{ github.event.inputs.prerelease_type }}" "${{ github.event.inputs.version }}"
# Read current version from package.json and append run number
CURRENT_VERSION=$(node -p "require('./package.json').version")
NEW_VERSION="${CURRENT_VERSION}-rc.${GITHUB_RUN_NUMBER}"
./scripts/publish-prerelease.sh "rc" "$NEW_VERSION"

# Upload artifacts for both paths
- name: Upload build artifacts
Expand Down
44 changes: 17 additions & 27 deletions js/scripts/publish-prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -euo pipefail
# Can be used both locally and in CI/CD
#
# Usage: ./publish-prerelease.sh <type> <version>
# type: beta, alpha, or rc
# version: explicit version to publish, e.g., 1.2.3-beta.1
# type: rc
# version: explicit version to publish, e.g., 1.2.3-rc.1

# Get directories
ROOT_DIR=$(git rev-parse --show-toplevel)
Expand All @@ -17,12 +17,10 @@ if [ $# -lt 2 ]; then
echo "Usage: $0 <type> <version>"
echo ""
echo "Arguments:"
echo " type: beta, alpha, or rc"
echo " type: rc"
echo " version: explicit version to publish"
echo ""
echo "Examples:"
echo " $0 beta 1.2.3-beta.1"
echo " $0 alpha 1.2.3-alpha.5"
echo "Example:"
echo " $0 rc 1.2.3-rc.1"
exit 1
fi
Expand All @@ -31,34 +29,26 @@ PRERELEASE_TYPE="$1"
VERSION="$2"

# Validate prerelease type
case "$PRERELEASE_TYPE" in
beta|alpha|rc)
;;
*)
echo "ERROR: Invalid prerelease type: $PRERELEASE_TYPE"
echo "Must be one of: beta, alpha, rc"
exit 1
;;
esac
if [ "$PRERELEASE_TYPE" != "rc" ]; then
echo "ERROR: Invalid prerelease type: $PRERELEASE_TYPE"
echo "Must be: rc"
exit 1
fi

# Validate version format
if [ -z "$VERSION" ]; then
echo "ERROR: Version cannot be empty"
exit 1
fi

# Map prerelease type to npm dist-tag
case "$PRERELEASE_TYPE" in
beta)
DIST_TAG="beta"
;;
alpha)
DIST_TAG="alpha"
;;
rc)
DIST_TAG="next"
;;
esac
# Validate that version contains the correct prerelease suffix
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc(\.[0-9]+)?$ ]]; then
echo "ERROR: Version '$VERSION' must include the prerelease type 'rc'"
echo "Expected format: X.Y.Z-rc.N (e.g., 1.2.3-rc.1)"
exit 1
fi

DIST_TAG="rc"

echo "================================================"
echo " Publishing Pre-release"
Expand Down
Loading