3939 TAG_VALUE="${TAG#v}"
4040 VERSION="${TAG_VALUE%-dry}"
4141
42+ if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.][[:alpha:]][[:alnum:]]*([.][0-9]+)?)?$ ]]; then
43+ echo "Tag version (${VERSION}) is not a valid RubyGems version" >&2
44+ exit 1
45+ fi
46+
4247 DRY_RUN=0
4348 if [ "${TAG_VALUE}" != "${VERSION}" ]; then
4449 DRY_RUN=1
@@ -54,19 +59,16 @@ jobs:
5459 exit 1
5560 fi
5661
57- if [[ "${VERSION}" == *-* ]]; then
62+ # RubyGems prerelease versions contain letters, e.g. 16.0.1.beta.0
63+ if [[ "${VERSION}" =~ [[:alpha:]] ]]; then
5864 PRERELEASE=true
5965 else
6066 PRERELEASE=false
6167 fi
6268
63- PUBLISH_TAG="$(npx -y semver-parser-cli@0.2.0 "${VERSION}" --field preid)"
64- if [ "${PUBLISH_TAG}" == "undefined" ] || [ -z "${PUBLISH_TAG}" ]; then
65- if [ "${PRERELEASE}" == "true" ]; then
66- PUBLISH_TAG=unnamed
67- else
68- PUBLISH_TAG=latest
69- fi
69+ PUBLISH_TAG=latest
70+ if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.([[:alpha:]][[:alnum:]]*)(\.[0-9]+)?$ ]]; then
71+ PUBLISH_TAG="${BASH_REMATCH[1]}"
7072 fi
7173
7274 echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
@@ -128,11 +130,17 @@ jobs:
128130 shell : bash
129131 env :
130132 VERSION : ${{ needs.prepare_release.outputs.version }}
133+ PRERELEASE : ${{ needs.prepare_release.outputs.prerelease }}
131134 run : |
132135 set -euo pipefail
133136
137+ FETCH_ARGS=(fastly --version "${VERSION}")
138+ if [ "${PRERELEASE}" = "true" ]; then
139+ FETCH_ARGS+=(--prerelease)
140+ fi
141+
134142 for i in 1 2 3 4 5; do
135- if gem fetch fastly --version "${VERSION }"; then
143+ if gem fetch "${FETCH_ARGS[@] }"; then
136144 break
137145 fi
138146 echo "Fetch attempt ${i} failed; retrying..."
0 commit comments