@@ -49,15 +49,34 @@ jobs:
4949 id : version
5050 shell : bash
5151 run : |
52+ set -euo pipefail
53+
5254 if [[ -n "${{ github.event.inputs.version }}" ]]; then
5355 VERSION="${{ github.event.inputs.version }}"
54- elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
55- VERSION="${GITHUB_REF#refs/tags/v}"
56+ elif [[ "${{ github.ref_type }}" == "tag" ]]; then
57+ # github.ref_name is e.g. "v0.2.4"
58+ TAG="${{ github.ref_name }}"
59+ VERSION="${TAG#v}"
5660 else
5761 VERSION="0.0.0-dev"
5862 fi
59- echo "version=${VERSION}" >> $GITHUB_OUTPUT
60- echo "SDK Version: ${VERSION}"
63+
64+ # Basic validation: must not be empty, must not start with v, no spaces
65+ if [[ -z "$VERSION" ]]; then
66+ echo "ERROR: Derived version is empty"
67+ exit 1
68+ fi
69+ if [[ "$VERSION" == v* ]]; then
70+ echo "ERROR: Derived version still has leading 'v': $VERSION"
71+ exit 1
72+ fi
73+ if [[ "$VERSION" =~ [[:space:]] ]]; then
74+ echo "ERROR: Version contains whitespace: '$VERSION'"
75+ exit 1
76+ fi
77+
78+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
79+ echo "SDK Version: $VERSION"
6180
6281 # ---------- vcpkg for Windows ----------
6382 - name : Export GitHub Actions cache environment variables
@@ -130,8 +149,17 @@ jobs:
130149 chmod +x build.sh
131150 version="${{ steps.version.outputs.version }}"
132151 bundleDir="sdk-out/livekit-sdk-${{ matrix.name }}-${version}"
152+ if [[ -z "$version" ]]; then
153+ echo "ERROR: version is empty"
154+ exit 1
155+ fi
133156
134- ./build.sh release-examples --bundle --prefix "$bundleDir"
157+ if [[ "$version" == "0.0.0-dev" ]]; then
158+ echo "ERROR: refusing to build release with fallback version: $version"
159+ exit 1
160+ fi
161+
162+ ./build.sh release-examples --version "$version" --bundle --prefix "$bundleDir"
135163
136164 # List bundle contents
137165 echo "Bundle contents:"
@@ -145,7 +173,8 @@ jobs:
145173 $version = "${{ steps.version.outputs.version }}"
146174 $bundleDir = "sdk-out/livekit-sdk-${{ matrix.name }}-$version"
147175
148- .\build.cmd release-examples --version $version
176+ if ([string]::IsNullOrWhiteSpace($version)) { throw "version is empty" }
177+ .\build.cmd release-examples --version "$version"
149178
150179 # There is the missing step that generates LiveKitTargets.cmake in the install tree
151180 # TODO(sxian): fix it after getting access to a windows machine
@@ -178,14 +207,30 @@ jobs:
178207 id : version
179208 shell : bash
180209 run : |
210+ set -euo pipefail
181211 if [[ -n "${{ github.event.inputs.version }}" ]]; then
182212 VERSION="${{ github.event.inputs.version }}"
183- elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
184- VERSION="${GITHUB_REF#refs/tags/v}"
213+ elif [[ "${{ github.ref_type }}" == "tag" ]]; then
214+ TAG="${{ github.ref_name }}"
215+ VERSION="${TAG#v}"
185216 else
186217 VERSION="0.0.0-dev"
187218 fi
188- echo "version=${VERSION}" >> $GITHUB_OUTPUT
219+
220+ if [[ -z "$VERSION" ]]; then
221+ echo "ERROR: Derived version is empty"
222+ exit 1
223+ fi
224+ if [[ "$VERSION" == v* ]]; then
225+ echo "ERROR: Derived version still has leading 'v': $VERSION"
226+ exit 1
227+ fi
228+ if [[ "$VERSION" =~ [[:space:]] ]]; then
229+ echo "ERROR: Version contains whitespace: '$VERSION'"
230+ exit 1
231+ fi
232+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
233+ echo "SDK Version: $VERSION"
189234
190235 - name : Download all artifacts
191236 uses : actions/download-artifact@v4
0 commit comments