forked from dotCMS/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dotCMS#28259 Testing publish-npm-sdks action.
- Loading branch information
Showing
6 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: 'SDK Publish NPM Packages' | ||
description: 'Publish the dotCMS SDK libs on NPM registry.' | ||
inputs: | ||
ref: | ||
description: 'Branch to build from' | ||
required: false | ||
default: 'master' | ||
node-version: | ||
description: 'Node.js version' | ||
required: false | ||
default: '19' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: 'Set up Node.js' | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
- name: 'Install dependencies' | ||
working-directory: ${{ github.workspace }}/core-web | ||
run: npm install | ||
shell: bash | ||
|
||
- name: 'Get current version from NPM' | ||
id: current_version | ||
run: | | ||
echo "::group::Get current version" | ||
CURRENT_VERSION=$(npm view @dotcms/client dist-tags --json | jq -r '.alpha') | ||
echo "Current version: $CURRENT_VERSION" | ||
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | ||
echo "::endgroup::" | ||
shell: bash | ||
|
||
- name: Calculate next version | ||
id: next_version | ||
env: | ||
CURRENT_VERSION: ${{ steps.current_version.outputs.current_version }} | ||
run: | | ||
echo "::group::Calculate next version" | ||
VERSION_PARTS=(${CURRENT_VERSION//./ }) | ||
BASE_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" | ||
ALPHA_PART=${VERSION_PARTS[3]#*-} | ||
ALPHA_NUMBER=${ALPHA_PART#*.} | ||
NEW_ALPHA_NUMBER=$((ALPHA_NUMBER + 1)) | ||
NEXT_VERSION="${BASE_VERSION}-alpha.${NEW_ALPHA_NUMBER}" | ||
echo "Next version: $NEXT_VERSION" | ||
echo "next_version::$NEXT_VERSION" >> $GITHUB_OUTPUT | ||
echo "::endgroup::" | ||
shell: bash | ||
|
||
- name: 'Printing versions' | ||
working-directory: ${{ github.workspace }}/core-web/libs/sdk/ | ||
env: | ||
NEXT_VERSION: ${{ steps.next_version.outputs.next_version }} | ||
CURRENT_VERSION: ${{ steps.current_version.outputs.current_version }} | ||
run: | | ||
echo "::group::Update versions" | ||
echo "Current version: $CURRENT_VERSION" | ||
echo "Next version: $NEXT_VERSION" | ||
echo "::endgroup::" | ||
shell: bash | ||
|
||
- name: 'Update versions and dependencies' | ||
working-directory: ${{ github.workspace }}/core-web/libs/sdk/ | ||
env: | ||
NEXT_VERSION: ${{ steps.next_version.outputs.next_version }} | ||
run: | | ||
echo "Updating version to $NEXT_VERSION" | ||
# npm version $NEXT_VERSION --no-git-tag-version | ||
SDKS=$(ls -ls core-web/libs/sdk | awk '{ print$10 }' | tr "," "\n") | ||
for dir in $(echo $SDKS); | ||
do | ||
echo "Updating $dir" | ||
(cd $dir && npm version $NEXT_VERSION --no-git-tag-version) | ||
done | ||
npm install | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,10 @@ on: | |
reuse-previous-build: | ||
default: false | ||
type: boolean | ||
publish-npm-package: | ||
publish-npm-cli: | ||
default: false | ||
type: boolean | ||
publish-npm-sdks: | ||
default: false | ||
type: boolean | ||
secrets: | ||
|
@@ -104,13 +107,21 @@ jobs: | |
|
||
- name: CLI Publish | ||
id: cli_publish | ||
if: inputs.publish-npm-package | ||
if: inputs.publish-npm-cli | ||
uses: ./.github/actions/publish-npm-cli | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
npm-token: ${{ secrets.NPM_ORG_TOKEN }} | ||
cli-artifact-run-id: ${{ github.run_id }} # currently cli artifacts are never from build queue | ||
|
||
- name: SDKs Publish | ||
id: sdks_publish | ||
if: inputs.publish-npm-sdks | ||
uses: ./.github/actions/publish-npm-sdks | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
npm-token: ${{ secrets.NPM_ORG_TOKEN }} | ||
sdk-artifact-run-id: ${{ github.run_id }} # currently sdk artifacts are never from build queue | ||
|
||
# A Slack notification is sent using the 'slackapi/slack-github-action' action if the repository is 'dotcms/core'. | ||
- name: Slack Notification (Docker image announcement) | ||
|
@@ -134,7 +145,7 @@ jobs: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | ||
|
||
- name: Slack Notification (dotCLI announcement) | ||
if: inputs.publish-npm-package | ||
if: inputs.publish-npm-cli | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: "log-dotcli" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters