Skip to content

Commit ee4a4e5

Browse files
chore(cicd): Added workflow and updated the sdk publish action (#33059)
This PR introduce the new workflow to manually execute the upgrate to patch, minor, major and custom version of our sdks. You can check the tests here: https://github.com/dotCMS/core-workflow-test/actions/workflows/cicd_manual-release-sdks.yml This PR fixes: #32597 --------- Co-authored-by: Kevin <[email protected]>
1 parent 1881587 commit ee4a4e5

File tree

2 files changed

+133
-3
lines changed

2 files changed

+133
-3
lines changed

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

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# DUAL PUBLISHING BEHAVIOR:
44
# LATEST TAG:
55
# - If current version contains "alpha" or "beta" -> publishes 1.0.0
6-
# - If stable version exists -> only publishes on explicit version-type (patch/minor/major/custom)
7-
# - Auto mode with stable version -> skips latest publishing
6+
# - If stable version exists -> publishes on explicit version-type (patch/minor/major/custom)
7+
# - Auto mode with stable version -> skips latest publishing (no version change)
88
#
99
# NEXT TAG:
1010
# - Always publishes with "-next.X" suffix where X increments
@@ -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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: 'Manual SDK Release'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version-type:
7+
description: 'Version increment type'
8+
required: true
9+
type: choice
10+
options:
11+
- 'patch'
12+
- 'minor'
13+
- 'major'
14+
- 'custom'
15+
default: 'patch'
16+
custom-version:
17+
description: 'Custom version (e.g., 1.3.4, 2.1.0) - only used when version-type is "custom"'
18+
required: false
19+
type: string
20+
default: ''
21+
ref:
22+
description: 'Branch to build from'
23+
required: false
24+
type: string
25+
default: 'main'
26+
27+
jobs:
28+
release-sdks:
29+
name: 'Release SDK Packages'
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: 'Checkout repository'
34+
uses: actions/checkout@v4
35+
with:
36+
ref: ${{ inputs.ref }}
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: 'Validate inputs'
40+
run: |
41+
echo "::group::Input validation"
42+
echo "Version type: ${{ inputs.version-type }}"
43+
echo "Custom version: ${{ inputs.custom-version }}"
44+
echo "Branch: ${{ inputs.ref }}"
45+
46+
# Validate that custom-version is provided when version-type is custom
47+
if [ "${{ inputs.version-type }}" = "custom" ]; then
48+
if [ -z "${{ inputs.custom-version }}" ]; then
49+
echo "::error::Custom version must be provided when version-type is 'custom'"
50+
echo "Please provide a valid semantic version (e.g., 1.3.4, 2.0.0, 1.2.1)"
51+
exit 1
52+
fi
53+
54+
# Basic semver validation
55+
if [[ ! "${{ inputs.custom-version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
56+
echo "::error::Invalid custom version format: '${{ inputs.custom-version }}'"
57+
echo "Version must follow semantic versioning format: major.minor.patch (e.g., 1.3.4)"
58+
exit 1
59+
fi
60+
61+
echo "✅ Custom version '${{ inputs.custom-version }}' is valid"
62+
fi
63+
echo "::endgroup::"
64+
65+
- name: 'Deploy JavaScript SDK'
66+
id: deploy-javascript-sdk
67+
uses: ./.github/actions/core-cicd/deployment/deploy-javascript-sdk
68+
with:
69+
ref: ${{ inputs.ref }}
70+
npm-token: ${{ secrets.NPM_TOKEN }}
71+
npm-package-tag: 'latest'
72+
version-type: ${{ inputs.version-type }}
73+
custom-version: ${{ inputs.custom-version }}
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: 'Display results'
77+
if: always()
78+
run: |
79+
echo "::group::Release Summary"
80+
echo "Version type used: ${{ steps.deploy-javascript-sdk.outputs.version-type-used || inputs.version-type }}"
81+
echo "Published to latest: ${{ steps.deploy-javascript-sdk.outputs.published-latest || 'unknown' }}"
82+
echo "Published to next: ${{ steps.deploy-javascript-sdk.outputs.published-next || 'unknown' }}"
83+
echo "NPM package version: ${{ steps.deploy-javascript-sdk.outputs.npm-package-version || 'unknown' }}"
84+
echo "Next version: ${{ steps.deploy-javascript-sdk.outputs.npm-package-version-next || 'unknown' }}"
85+
echo "::endgroup::"

0 commit comments

Comments
 (0)