Skip to content

Commit fa51580

Browse files
chore: fix channel detection script
1 parent 76aa332 commit fa51580

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.github/workflows/publish.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,26 @@ jobs:
4545
fi
4646
- name: Get npm tag
4747
id: npm-tag
48+
shell: bash
4849
run: |
49-
$regex = "^v?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:[^.]*)))?"
50-
$version = "${{ steps.get-version.outputs.VERSION }}"
51-
$releaseChannel = $groups["prerelease"][0].value
50+
VERSION="${{ steps.get-version.outputs.VERSION }}"
51+
52+
# Extract the release channel (latest, alpha, beta, rc)
53+
if [[ $VERSION =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(.+))?$ ]]; then
54+
if [[ -n "${BASH_REMATCH[5]}" ]]; then
55+
CAPTURED_CHANNEL="${BASH_REMATCH[5]}"
56+
# The captured channel might have more dots, cases like
57+
# v1.2.3-alpha.1 For such cases we only want the channel relevant
58+
# part which is alpha.
59+
RELEASE_CHANNEL="${CAPTURED_CHANNEL%%.*}"
60+
else
61+
RELEASE_CHANNEL="latest"
62+
fi
63+
else
64+
RELEASE_CHANNEL="latest"
65+
fi
5266
53-
if ([string]::IsNullOrEmpty($releaseChannel)) {
54-
$releaseChannel = "latest"
55-
}
56-
Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT
67+
echo "RELEASE_CHANNEL=${RELEASE_CHANNEL}" >> "$GITHUB_OUTPUT"
5768
- name: Output deployment info
5869
run: echo "::notice title=Deployment Info::Deploying version ${{ steps.get-version.outputs.VERSION }} to channel ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}"
5970

0 commit comments

Comments
 (0)