1- # Note: The versions of the SDK libraries will be incremented in the NPM registry,
2- # but they will not be updated in the codebase itself through this process.
3- # This simplification avoids automatic pull requests and all the considerations
4- # necessary due to protections on the main branch, as well as the lengthy execution
1+ # Note: The versions of the SDK libraries will be incremented in the NPM registry,
2+ # but they will not be updated in the codebase itself through this process.
3+ # This simplification avoids automatic pull requests and all the considerations
4+ # necessary due to protections on the main branch, as well as the lengthy execution
55# process that would be required to ultimately publish the libraries.
6- #
7- # This is a temporary solution until we determine the most appropriate pattern
8- # to handle the lifecycle of each module that needs to be released individually
6+ #
7+ # This is a temporary solution until we determine the most appropriate pattern
8+ # to handle the lifecycle of each module that needs to be released individually
99# (e.g., dotCLI and the SDKs).
1010#
11- # Additionally, the example projects should point to the 'latest ' tag to ensure
11+ # Additionally, the example projects should point to the 'next ' tag to ensure
1212# that version updates do not impact their functionality due to version inconsistency.
1313name : ' SDK Publish NPM Packages'
1414description : ' Publish the dotCMS SDK libs on NPM registry.'
@@ -23,10 +23,10 @@ inputs:
2323 npm-package-tag :
2424 description : ' Package tag'
2525 required : false
26- default : ' alpha '
26+ default : ' beta '
2727 github-token :
2828 description : ' GitHub Token'
29- required : true
29+ required : true
3030outputs :
3131 npm-package-version :
3232 description : ' SDK libs - NPM package version'
@@ -62,33 +62,40 @@ runs:
6262 ls -R $BASE_PATH
6363 echo "PATH=$PATH:${BASE_PATH}/node/:${BASE_PATH}/node/yarn/dist/bin" >> $GITHUB_ENV
6464 echo "::endgroup::"
65- shell : bash
65+ shell : bash
6666
6767 - name : ' Get current version from NPM'
6868 id : current_version
6969 run : |
70- echo "::group::Get current version"
71- CURRENT_VERSION=$(npm view @dotcms/client dist-tags --json | jq -r '.alpha')
72- echo "Current version: $CURRENT_VERSION"
73- echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
74- echo "::endgroup::"
70+ echo "::group::Get current version"
71+ # This should be empty on the first run. Setting the NEXT_VERSION to 0.0.1-beta.1
72+ CURRENT_VERSION=$(npm view @dotcms/client dist-tags --json | jq -r '.beta')
73+
74+ if [ -z "$CURRENT_VERSION" ]; then
75+ CURRENT_VERSION="0.0.1-beta.0"
76+ fi
77+
78+ echo "Current version: $CURRENT_VERSION"
79+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
80+ echo "::endgroup::"
7581 shell : bash
7682
7783 - name : ' Calculate next version'
7884 id : next_version
7985 env :
8086 CURRENT_VERSION : ${{ steps.current_version.outputs.current_version }}
8187 run : |
82- echo "::group::Calculate next version"
83- VERSION_PARTS=(${CURRENT_VERSION//./ })
84- BASE_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
85- ALPHA_PART=${VERSION_PARTS[3]#*-}
86- ALPHA_NUMBER=${ALPHA_PART#*.}
87- NEW_ALPHA_NUMBER=$((ALPHA_NUMBER + 1))
88- NEXT_VERSION="${BASE_VERSION}.${NEW_ALPHA_NUMBER}"
89- echo "Next version: $NEXT_VERSION"
90- echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
91- echo "::endgroup::"
88+ echo "::group::Calculate next version"
89+ VERSION_PARTS=(${CURRENT_VERSION//./ })
90+ BASE_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
91+ BETA_PART=${VERSION_PARTS[3]#*-}
92+ BETA_NUMBER=${BETA_PART#*.}
93+ NEW_BETA_NUMBER=$((BETA_NUMBER + 1))
94+ NEXT_VERSION="${BASE_VERSION}.${NEW_BETA_NUMBER}"
95+ echo "Next version: $NEXT_VERSION"
96+ echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
97+ echo "::endgroup::"
98+
9299 shell : bash
93100
94101 - name : ' Printing versions'
@@ -110,27 +117,27 @@ runs:
110117 EXAMPLES_PATH : ${{ github.workspace }}/examples
111118 run : |
112119 echo "Updating version to $NEXT_VERSION"
113-
120+
114121 # Function to update the version in package.json using jq
115122 update_version() {
116123 local pkg_dir="$1"
117124 local new_version="$2"
118125 local package_json_path="$pkg_dir/package.json"
119-
126+
120127 if [ -f "$package_json_path" ]; then
121128 jq --arg new_version "$new_version" '.version = $new_version' "$package_json_path" > tmp.$$.json && mv tmp.$$.json "$package_json_path"
122129 echo "Updated version in $package_json_path to $new_version"
123130 else
124131 echo "::warn::Warning: No package.json found in $pkg_dir"
125132 fi
126133 }
127-
134+
128135 # Function to update peerDependencies in package.json
129136 update_peer_dependencies() {
130137 local pkg_dir="$1"
131138 local new_version="$2"
132139 local package_json_path="$pkg_dir/package.json"
133-
140+
134141 if [ -f "$package_json_path" ]; then
135142 for dep in "${sdk_packages[@]}"; do
136143 if jq -e ".peerDependencies[\"@dotcms/$dep\"]" "$package_json_path" >/dev/null; then
@@ -144,13 +151,13 @@ runs:
144151 echo "::warn::Warning: No package.json found in $pkg_dir"
145152 fi
146153 }
147-
154+
148155 # Function to update dependencies in examples package.json
149156 update_dependencies_in_examples() {
150157 local example_dir="$1"
151158 local new_version="$2"
152159 local package_json_path="$example_dir/package.json"
153-
160+
154161 if [ -f "$package_json_path" ]; then
155162 for dep in "${sdk_packages[@]}"; do
156163 if jq -e ".dependencies[\"@dotcms/$dep\"]" "$package_json_path" >/dev/null; then
@@ -166,20 +173,20 @@ runs:
166173 echo "::warn::Warning: No package.json found in $example_dir"
167174 fi
168175 }
169-
176+
170177 # Detect all SDK packages dynamically in the libs/sdk directory
171178 sdk_packages=($(find . -maxdepth 1 -type d -exec basename {} \; | grep -v "^\.$"))
172-
179+
173180 # Step 1: Update the version in each SDK package
174181 for sdk in "${sdk_packages[@]}"; do
175182 update_version "$sdk" "$NEXT_VERSION"
176183 done
177-
184+
178185 # Step 2: Update peerDependencies in each SDK package
179186 for sdk in "${sdk_packages[@]}"; do
180187 update_peer_dependencies "$sdk" "$NEXT_VERSION"
181188 done
182-
189+
183190 # Step 3: Update dependencies in example projects
184191 example_packages=$(find $EXAMPLES_PATH -name "package.json" -not -path "*/node_modules/*")
185192
@@ -201,19 +208,19 @@ runs:
201208 echo "::group::Printing SDK and Example packages"
202209 echo "SDK libs:"
203210 print_packages "$SDK_LIBS_PATH"
204- echo ""
211+ echo ""
205212 echo "Examples:"
206213 print_packages "$EXAMPLES_PATH"
207214 echo "::endgroup::"
208- shell : bash
215+ shell : bash
209216
210217 - name : ' Install project'
211218 working-directory : ${{ github.workspace }}/core-web/
212- run : |
219+ run : |
213220 yarn install
214221 npm --version
215222 node --version
216- npx --version
223+ npx --version
217224 shell : bash
218225
219226 - name : ' Build SDK packages'
@@ -229,14 +236,14 @@ runs:
229236 NPM_AUTH_TOKEN : ${{ inputs.npm-token }}
230237 NPM_TAG : ${{ inputs.npm-package-tag }}
231238 run : |
232- echo "::group::Publishing SDK packages"
239+ echo "::group::Publishing SDK packages"
233240 sdks=$(ls)
234241 for sdk in $sdks; do
235242 echo "Publishing SDK lib [${sdk}]"
236243 cd $sdk && echo "$(pwd)"
237244 echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ~/.npmrc
238245 npm publish --access public --tag $NPM_TAG
239- npm dist-tag add @dotcms/${sdk}@${NEXT_VERSION} latest
246+ npm dist-tag add @dotcms/${sdk}@${NEXT_VERSION} next
240247 cd ..
241248 done
242249 echo "::endgroup::"
0 commit comments