Skip to content

Commit 6628be6

Browse files
Update action.yml (#409)
### Proposed Changes * change 1 * change 2 ### Checklist - [ ] Tests - [ ] Translations - [ ] Security Implications Contemplated (add notes if applicable) ### Additional Info ** any additional useful context or info ** ### Screenshots Original | Updated :-------------------------:|:-------------------------: ** original screenshot ** | ** updated screenshot **
1 parent f860e05 commit 6628be6

File tree

1 file changed

+46
-1
lines changed
  • .github/actions/core-cicd/deployment/deploy-javascript-sdk

1 file changed

+46
-1
lines changed

.github/actions/core-cicd/deployment/deploy-javascript-sdk/action.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ runs:
127127
if: ${{ inputs.version-type == 'custom' }}
128128
env:
129129
CUSTOM_VERSION: ${{ inputs.custom-version }}
130+
CURRENT_STABLE: ${{ steps.current_version.outputs.current_stable }}
131+
CURRENT_BETA: ${{ steps.current_version.outputs.current_beta }}
132+
CURRENT_NEXT: ${{ steps.current_version.outputs.current_next }}
130133
run: |
131134
echo "::group::Validate custom version"
132135
@@ -140,10 +143,52 @@ runs:
140143
if [[ ! "$CUSTOM_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
141144
echo "::error::Invalid custom version format: '$CUSTOM_VERSION'"
142145
echo "Version must follow semantic versioning format: major.minor.patch (e.g., 1.3.4)"
146+
echo "Examples of valid versions: 1.0.0, 2.1.3, 10.15.7"
143147
exit 1
144148
fi
145149
146-
echo "✅ Custom version '$CUSTOM_VERSION' is valid"
150+
# Check if custom version already exists in NPM
151+
echo "Checking if version $CUSTOM_VERSION already exists in NPM..."
152+
153+
# Compare against current stable version
154+
if [ -n "$CURRENT_STABLE" ] && [ "$CURRENT_STABLE" != "null" ] && [ "$CURRENT_STABLE" = "$CUSTOM_VERSION" ]; then
155+
echo "::error::Custom version $CUSTOM_VERSION already exists as the current stable (latest) version"
156+
echo "Please choose a different version number that hasn't been published yet"
157+
echo "Current stable version: $CURRENT_STABLE"
158+
exit 1
159+
fi
160+
161+
# Compare against current beta version
162+
if [ -n "$CURRENT_BETA" ] && [ "$CURRENT_BETA" != "null" ] && [ "$CURRENT_BETA" = "$CUSTOM_VERSION" ]; then
163+
echo "::error::Custom version $CUSTOM_VERSION already exists as the current beta version"
164+
echo "Please choose a different version number that hasn't been published yet"
165+
echo "Current beta version: $CURRENT_BETA"
166+
exit 1
167+
fi
168+
169+
# Compare against current next version (extract base version)
170+
if [ -n "$CURRENT_NEXT" ] && [ "$CURRENT_NEXT" != "null" ]; then
171+
CURRENT_NEXT_BASE=$(echo "$CURRENT_NEXT" | sed 's/-next\.[0-9]*$//')
172+
if [ "$CURRENT_NEXT_BASE" = "$CUSTOM_VERSION" ]; then
173+
echo "::error::Custom version $CUSTOM_VERSION already exists as the base version for current next tag"
174+
echo "Please choose a different version number that hasn't been published yet"
175+
echo "Current next version: $CURRENT_NEXT (base: $CURRENT_NEXT_BASE)"
176+
exit 1
177+
fi
178+
fi
179+
180+
# Additional check: Query NPM directly to see if this exact version exists
181+
echo "Performing direct NPM registry check for version $CUSTOM_VERSION..."
182+
if npm view @dotcms/client@$CUSTOM_VERSION version >/dev/null 2>&1; then
183+
echo "::error::Custom version $CUSTOM_VERSION already exists in NPM registry"
184+
echo "Please choose a different version number that hasn't been published yet"
185+
echo "You can check existing versions with: npm view @dotcms/client versions --json"
186+
exit 1
187+
fi
188+
189+
echo "✅ Custom version '$CUSTOM_VERSION' is valid and unique"
190+
echo "✅ Semantic version format check: PASSED"
191+
echo "✅ NPM registry uniqueness check: PASSED"
147192
echo "::endgroup::"
148193
shell: bash
149194

0 commit comments

Comments
 (0)