diff --git a/.github/workflows/publish-js-sdk.yaml b/.github/workflows/publish-js-sdk.yaml index 7f41c9705..c9cc817fa 100644 --- a/.github/workflows/publish-js-sdk.yaml +++ b/.github/workflows/publish-js-sdk.yaml @@ -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 # @@ -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: @@ -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 diff --git a/js/scripts/publish-prerelease.sh b/js/scripts/publish-prerelease.sh index 81d8877ab..d263adcf6 100755 --- a/js/scripts/publish-prerelease.sh +++ b/js/scripts/publish-prerelease.sh @@ -5,8 +5,8 @@ set -euo pipefail # Can be used both locally and in CI/CD # # Usage: ./publish-prerelease.sh -# 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) @@ -17,12 +17,10 @@ if [ $# -lt 2 ]; then echo "Usage: $0 " 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 @@ -31,15 +29,11 @@ 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 @@ -47,18 +41,14 @@ if [ -z "$VERSION" ]; then 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"