Skip to content

Commit 1c2477b

Browse files
Update action.yml (#410)
### 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 6628be6 commit 1c2477b

File tree

1 file changed

+78
-28
lines changed
  • .github/actions/core-cicd/deployment/deploy-javascript-sdk

1 file changed

+78
-28
lines changed

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

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,41 +85,79 @@ runs:
8585
echo "::endgroup::"
8686
shell: bash
8787

88-
- name: 'Get current version from NPM'
88+
- name: 'Detect SDK packages and check NPM status'
8989
id: current_version
90+
working-directory: ${{ github.workspace }}/core-web/libs/sdk/
9091
run: |
91-
echo "::group::Get current version"
92+
echo "::group::Detect SDK packages and check NPM status"
9293
93-
# Get the current stable version from the latest tag
94-
CURRENT_STABLE=$(npm view @dotcms/client dist-tags --json 2>/dev/null | jq -r '.latest // empty')
94+
# Detect all SDK packages dynamically
95+
sdk_packages=($(find . -maxdepth 1 -type d -exec basename {} \; | grep -v "^\.$"))
96+
echo "Found SDK packages: ${sdk_packages[*]}"
9597
96-
# Get the current beta version for reference
97-
CURRENT_BETA=$(npm view @dotcms/client dist-tags --json 2>/dev/null | jq -r '.beta // empty')
98+
# Check the status of each package and find the highest version
99+
HIGHEST_VERSION="0.0.0"
100+
VERSION_SOURCE="none"
101+
PACKAGES_STATUS=""
98102
99-
# Get the current next version
100-
CURRENT_NEXT=$(npm view @dotcms/client dist-tags --json 2>/dev/null | jq -r '.next // empty')
103+
for sdk in "${sdk_packages[@]}"; do
104+
echo ""
105+
echo "🔍 Checking @dotcms/${sdk}..."
106+
107+
# Check if package exists in NPM
108+
if npm view @dotcms/${sdk} >/dev/null 2>&1; then
109+
# Package exists, get current versions
110+
STABLE_VERSION=$(npm view @dotcms/${sdk} dist-tags --json 2>/dev/null | jq -r '.latest // empty')
111+
112+
echo " ✅ Package exists - Latest: ${STABLE_VERSION:-'none'}"
113+
114+
# Update highest version if this package has a higher stable version
115+
if [ -n "$STABLE_VERSION" ] && [ "$STABLE_VERSION" != "null" ] && [ "$STABLE_VERSION" != "empty" ]; then
116+
if [ "$STABLE_VERSION" != "0.0.0" ]; then
117+
if [ "$HIGHEST_VERSION" = "0.0.0" ] || [ "$(printf '%s\n' "$STABLE_VERSION" "$HIGHEST_VERSION" | sort -V | tail -n1)" = "$STABLE_VERSION" ]; then
118+
HIGHEST_VERSION="$STABLE_VERSION"
119+
VERSION_SOURCE="existing"
120+
fi
121+
fi
122+
fi
123+
124+
PACKAGES_STATUS="${PACKAGES_STATUS}${sdk}:exists,"
125+
else
126+
echo " 📦 Package doesn't exist yet (first-time publication)"
127+
PACKAGES_STATUS="${PACKAGES_STATUS}${sdk}:new,"
128+
fi
129+
done
101130
102-
# Determine the current version to use as base
103-
if [ -n "$CURRENT_STABLE" ] && [ "$CURRENT_STABLE" != "null" ]; then
104-
CURRENT_VERSION="$CURRENT_STABLE"
105-
VERSION_SOURCE="stable"
106-
elif [ -n "$CURRENT_BETA" ] && [ "$CURRENT_BETA" != "null" ]; then
107-
CURRENT_VERSION="$CURRENT_BETA"
108-
VERSION_SOURCE="beta"
131+
# Determine the base version to use
132+
if [ "$VERSION_SOURCE" = "existing" ]; then
133+
CURRENT_VERSION="$HIGHEST_VERSION"
134+
echo ""
135+
echo "📊 Using highest existing version: $CURRENT_VERSION"
109136
else
110137
CURRENT_VERSION="0.0.0"
111138
VERSION_SOURCE="none"
139+
echo ""
140+
echo "📦 No existing packages found, starting fresh with 0.0.0 base"
112141
fi
113-
114-
echo "Current stable version: ${CURRENT_STABLE:-'none'}"
115-
echo "Current beta version: ${CURRENT_BETA:-'none'}"
116-
echo "Current next version: ${CURRENT_NEXT:-'none'}"
117-
echo "Using version: $CURRENT_VERSION (source: $VERSION_SOURCE)"
142+
143+
# For backward compatibility
144+
if [ "$CURRENT_VERSION" != "0.0.0" ]; then
145+
CURRENT_STABLE="$CURRENT_VERSION"
146+
else
147+
CURRENT_STABLE=""
148+
fi
149+
150+
echo ""
151+
echo "=== PACKAGE STATUS SUMMARY ==="
152+
echo "Base version: $CURRENT_VERSION"
153+
echo "Version source: $VERSION_SOURCE"
154+
echo "==============================="
118155
119156
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
120157
echo "version_source=$VERSION_SOURCE" >> $GITHUB_OUTPUT
121158
echo "current_stable=$CURRENT_STABLE" >> $GITHUB_OUTPUT
122-
echo "current_next=$CURRENT_NEXT" >> $GITHUB_OUTPUT
159+
echo "current_beta=" >> $GITHUB_OUTPUT
160+
echo "current_next=" >> $GITHUB_OUTPUT
123161
echo "::endgroup::"
124162
shell: bash
125163

@@ -177,14 +215,26 @@ runs:
177215
fi
178216
fi
179217
180-
# Additional check: Query NPM directly to see if this exact version exists
218+
# Additional check: Query NPM directly to see if this exact version exists in any existing package
181219
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
220+
221+
# Get SDK packages dynamically and check if any existing package has this version
222+
cd ${{ github.workspace }}/core-web/libs/sdk/
223+
sdk_packages=($(find . -maxdepth 1 -type d -exec basename {} \; | grep -v "^\.$"))
224+
225+
for sdk in "${sdk_packages[@]}"; do
226+
if npm view @dotcms/${sdk} >/dev/null 2>&1; then
227+
# Package exists, check if this version exists
228+
if npm view @dotcms/${sdk}@$CUSTOM_VERSION version >/dev/null 2>&1; then
229+
echo "::error::Custom version $CUSTOM_VERSION already exists in NPM registry for @dotcms/${sdk}"
230+
echo "Please choose a different version number that hasn't been published yet"
231+
echo "You can check existing versions with: npm view @dotcms/${sdk} versions --json"
232+
exit 1
233+
fi
234+
fi
235+
done
236+
237+
cd - >/dev/null
188238
189239
echo "✅ Custom version '$CUSTOM_VERSION' is valid and unique"
190240
echo "✅ Semantic version format check: PASSED"

0 commit comments

Comments
 (0)