From b12bbd9635daa77c93730b90474321f3ff792472 Mon Sep 17 00:00:00 2001 From: Himanshu Singh Date: Wed, 10 Sep 2025 13:22:25 +0200 Subject: [PATCH 1/3] chore: fix channel detection script --- .github/workflows/publish.yaml | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b012205db..43a28e876 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -45,15 +45,26 @@ jobs: fi - name: Get npm tag id: npm-tag + shell: bash run: | - $regex = "^v?(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:[^.]*)))?" - $version = "${{ steps.get-version.outputs.VERSION }}" - $releaseChannel = $groups["prerelease"][0].value + VERSION="${{ steps.get-version.outputs.VERSION }}" + + # Extract the release channel (latest, alpha, beta, rc) + if [[ $VERSION =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(.+))?$ ]]; then + if [[ -n "${BASH_REMATCH[5]}" ]]; then + CAPTURED_CHANNEL="${BASH_REMATCH[5]}" + # The captured channel might have more dots, cases like + # v1.2.3-alpha.1 For such cases we only want the channel relevant + # part which is alpha. + RELEASE_CHANNEL="${CAPTURED_CHANNEL%%.*}" + else + RELEASE_CHANNEL="latest" + fi + else + RELEASE_CHANNEL="latest" + fi - if ([string]::IsNullOrEmpty($releaseChannel)) { - $releaseChannel = "latest" - } - Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT + echo "RELEASE_CHANNEL=${RELEASE_CHANNEL}" >> "$GITHUB_OUTPUT" - name: Output deployment info run: echo "::notice title=Deployment Info::Deploying version ${{ steps.get-version.outputs.VERSION }} to channel ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}" From 21c7e2a4b2d0fcaedb55fba990e5d5a60e8fdc3b Mon Sep 17 00:00:00 2001 From: Himanshu Singh Date: Wed, 10 Sep 2025 13:38:18 +0200 Subject: [PATCH 2/3] chore: PR feedback - remove unused captured groups --- .github/workflows/publish.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 43a28e876..0a93b0077 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -50,9 +50,9 @@ jobs: VERSION="${{ steps.get-version.outputs.VERSION }}" # Extract the release channel (latest, alpha, beta, rc) - if [[ $VERSION =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(.+))?$ ]]; then - if [[ -n "${BASH_REMATCH[5]}" ]]; then - CAPTURED_CHANNEL="${BASH_REMATCH[5]}" + if [[ $VERSION =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-(.+))?$ ]]; then + if [[ -n "${BASH_REMATCH[2]}" ]]; then + CAPTURED_CHANNEL="${BASH_REMATCH[2]}" # The captured channel might have more dots, cases like # v1.2.3-alpha.1 For such cases we only want the channel relevant # part which is alpha. From 93dad7b67cc6dbfa5808468d4c3629a4412c1329 Mon Sep 17 00:00:00 2001 From: Himanshu Singh Date: Wed, 10 Sep 2025 14:25:34 +0200 Subject: [PATCH 3/3] chore: PR feedback exit with non-zero on regex not match --- .github/workflows/publish.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0a93b0077..0513b2220 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -47,6 +47,7 @@ jobs: id: npm-tag shell: bash run: | + set -e VERSION="${{ steps.get-version.outputs.VERSION }}" # Extract the release channel (latest, alpha, beta, rc) @@ -61,7 +62,8 @@ jobs: RELEASE_CHANNEL="latest" fi else - RELEASE_CHANNEL="latest" + echo "::error title=Invalid Version::Encountered unexpected version ${{ steps.get-version.outputs.VERSION }}, cannot proceed!" + exit 1 fi echo "RELEASE_CHANNEL=${RELEASE_CHANNEL}" >> "$GITHUB_OUTPUT"