Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f507c5c
fix(pipeline): create-new-pipeline-for-publishing (#314)
Shreyas281299 Nov 19, 2024
10531f7
chore(release): 1.27.6-eft.1 [skip ci]
webex-components-publisher Nov 19, 2024
09e8912
fix(cc-store): try-patch-release (#315)
Shreyas281299 Nov 19, 2024
af2a9b8
chore(release): 1.27.6-eft.2 [skip ci]
webex-components-publisher Nov 19, 2024
9dd3461
feat(cc-user-state): try-minor-release (#316)
Shreyas281299 Nov 19, 2024
bb17741
chore(release): 1.28.0-eft.1 [skip ci]
webex-components-publisher Nov 19, 2024
20dfb7a
fix(release): update-files-that-are-published-to-npm (#317)
Shreyas281299 Nov 19, 2024
5daeeea
chore(release): 1.28.0-eft.2 [skip ci]
webex-components-publisher Nov 19, 2024
5d0a65e
fix(release): create-tag-without-npm-publish (#318)
Shreyas281299 Nov 19, 2024
445e8a7
chore(release): 1.28.0-eft.3 [skip ci]
webex-components-publisher Nov 19, 2024
7e20bec
fix(release): update-publishing-logic (#320)
Shreyas281299 Nov 20, 2024
7e28d02
chore(release): 1.28.0-eft.4 [skip ci]
webex-components-publisher Nov 20, 2024
3dc6f9f
fix(release): add-testing-step-in-circleci (#321)
Shreyas281299 Nov 20, 2024
3e11c58
chore(release): 1.28.0-eft.5 [skip ci]
webex-components-publisher Nov 20, 2024
e01591c
fix(release): fix-pr-checks (#322)
Shreyas281299 Nov 20, 2024
72b6672
chore(release): 1.28.0-eft.6 [skip ci]
webex-components-publisher Nov 20, 2024
25eb283
fix(release): change-changelog-md-file-location (#323)
Shreyas281299 Nov 20, 2024
4b87ffd
chore(release): 1.28.0-eft.7 [skip ci]
webex-components-publisher Nov 20, 2024
1c67f46
fix(release): wxcc-branch-specific-changes
Nov 20, 2024
eb6561e
fix(release): self-review
Nov 20, 2024
604e030
fix(release): formatting-changes
Nov 20, 2024
2d612b7
fix(release): update-config-yml
Nov 20, 2024
fb2cee0
fix(release): remove-publish-step-from-pipeline
Nov 20, 2024
7a7e976
fix(release): update-publish-to-get-name-from-packagejson
Nov 20, 2024
f36f2bb
fix(release): add-publish-logic-back-for-testing
Nov 20, 2024
a253f02
fix(release): remove-publish-step
Nov 20, 2024
f348033
fix(release): fix-tooling-ut
Nov 20, 2024
bd8d772
fix(release): review-comments
Nov 20, 2024
e9e310b
fix(release): remove-unused-variable
Nov 21, 2024
50db292
fix(release): add-v-in-tagformat
Nov 21, 2024
881d71d
fix(release): release-on-github-with-v
Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
root: .
paths:
- node_modules
- packages/*/node_modules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have changed the file structure packages will be inside package/**/*
Examples :
packages/contact-center/node_modules
packages/widgets/node_modules (https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-583602)

- packages/**/*/node_modules

linter:
executor: node-executor
Expand All @@ -61,10 +61,13 @@ jobs:
- checkout_from_workspace
- run:
name: Build
command: yarn workspace @webex/widgets run build
command: yarn run build && yarn workspace @webex/widgets run build
- persist_to_workspace:
root: .
paths:
- packages/contact-center/station-login/dist
- packages/contact-center/store/dist
- packages/contact-center/user-state/dist
- packages/@webex/widgets/dist

docs:
Expand All @@ -87,6 +90,25 @@ jobs:
name: Release
command: yarn workspace @webex/widgets run release

unit_tests:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unit test step in pipeline. We test tooling first and then cc-widgets.

executor: node-executor
steps:
- checkout_from_workspace
- run:
name: Test Tooling
command: yarn run test:tooling
- run:
name: Test CC Widgets
command: yarn run test:cc-widgets

release_widgets:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step will only release cc-widgets

executor: node-executor
steps:
- checkout_from_workspace
- run:
name: Release Widgets
command: yarn run release:widgets

# execute the jobs in an orderly manner
workflows:
setup_test_release:
Expand All @@ -98,19 +120,32 @@ workflows:
- build:
requires:
- linter
filters:
branches:
only: master

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing the filter we make sure that build step runs on PRs as well.
Screenshot 2024-11-20 at 2 36 16 PM

- docs:
requires:
- linter
filters:
branches:
only: master
only:
- master

- unit_tests:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run unit-tests on PRs

requires:
- build

- release:
requires:
- build
- docs
filters:
branches:
only: master


- release_widgets:
requires:
- build
- unit_tests
filters:
branches:
only: feat/cc-widgets

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This make sure we only release ccwidgets when we push onto feat/cc-widgets branch

33 changes: 33 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"branches": [
"master",
{
"name": "feat/cc-widgets",
"prerelease": "wxcc"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "packages/contact-center/CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": [
"packages/contact-center/CHANGELOG.md",
"package.json",
"packages/contact-center/*/package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
"tagFormat": "$v{nextRelease.version}"
}
],
"@semantic-release/github"
],
"tagFormat":"v${version}"
}
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,38 @@
],
"packageManager": "yarn@4.5.1",
"devDependencies": {
"@babel/preset-typescript": "7.25.9",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"html-webpack-plugin": "^5.6.3",
"jest": "29.7.0",
"node-gyp": "^10.2.0",
"semantic-release": "^24.2.0",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
},
"scripts": {
"test:unit": "yarn run test:tooling && yarn run test:cc-widgets",
"test:tooling": "jest --coverage",
"test:cc-widgets": "yarn run test:store && yarn run test:widgets",
"test:store": "yarn workspace @webex/cc-store test:unit",
"test:widgets": "yarn workspace @webex/cc-station-login test:unit && yarn workspace @webex/cc-user-state test:unit",
Comment on lines +29 to +33

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test:unit will run all the tests.

@sreenara sreenara Dec 6, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a suggestion for improvement. We could use yarn workspaces foreach when we'd like to run the same command across different packages @Shreyas281299

"build": "yarn run build:store && yarn run build:widgets",
"build:store": "yarn workspace @webex/cc-store build:src",
"build:widgets": "yarn workspace @webex/cc-station-login build:src && yarn workspace @webex/cc-user-state build:src",
"samples:build": "yarn workspace @webex/react-samples-app build:src && yarn workspace @webex/web-component-samples-app build:src",
"samples:serve": "open docs/index.html && yarn workspace @webex/react-samples-app serve",
"samples:serve-react": "yarn workspace @webex/react-samples-app serve",
"samples:serve-wc": "yarn workspace @webex/web-component-samples-app serve"
"samples:serve-wc": "yarn workspace @webex/web-component-samples-app serve",
"release:widgets": "semantic-release"
},
"jest": {
"testMatch": [
"**/tooling/tests/*.js"
]
Comment on lines +44 to +46

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we run `yarn run test:tooling' this is what make sure we only run tooling.

}
}
7 changes: 7 additions & 0 deletions packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"description": "Webex Contact Center Widgets: Station Login",
"version": "1.0.0",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"package.json"
],
Comment on lines +9 to +12

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that we only publish the dist and package.json to npmjs

"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
Expand Down
11 changes: 10 additions & 1 deletion packages/contact-center/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"package.json"
],
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
Expand Down Expand Up @@ -37,6 +44,8 @@
"webpack-merge": "6.0.1"
},
"jest": {
"testEnvironment": "jsdom"
"testEnvironment": "jsdom",
"//": "We can remove this when we have tests",
"passWithNoTests": true
Comment thread
mkesavan13 marked this conversation as resolved.
}
}
11 changes: 10 additions & 1 deletion packages/contact-center/user-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"description": "Webex Contact Center Widgets: User State",
"version": "1.0.0",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"package.json"
],
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
Expand Down Expand Up @@ -38,6 +45,8 @@
"webpack-merge": "6.0.1"
},
"jest": {
"testEnvironment": "jsdom"
"testEnvironment": "jsdom",
"//": "We can remove this when we have tests",
"passWithNoTests": true
Comment thread
mkesavan13 marked this conversation as resolved.
}
}
83 changes: 83 additions & 0 deletions tooling/src/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const {execSync} = require('child_process');
const fs = require('fs');
const path = require('path');

// Function to remove the 'stableVersion' key
function removeStableVersion(packageJsonPath, packageData) {
try {
if (packageData.hasOwnProperty('stableVersion')) {
delete packageData.stableVersion;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
console.log("'stableVersion' key removed successfully.");
} else {
console.log("'stableVersion' key does not exist in package.json.");
}
} catch (error) {
throw new Error("An error occurred while removing 'stableVersion':", error.message);
}
}

function versionAndPublish() {
const branchName = process.argv[2];
const newVersion = process.argv[3];

if (!branchName || !newVersion) {
console.error(
'Error: Not enough positional arguments provided! node <relative_path_to_publish> <branchName> <nextVersion>'
);
process.exit(1);
}
const contactCenterPath = './packages/contact-center';
const dependencies = ['@webex/cc-store'];

try {
const ccFolder = fs
.readdirSync(contactCenterPath, {withFileTypes: true})
.filter((dirent) => {
return dirent.isDirectory();
})
.map((dirent) => {
try {
const packageJsonPath = path.join(contactCenterPath, dirent.name, 'package.json');
const packageData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

console.log(`Removing stable version from package.json for ${dirent.name}`);
removeStableVersion(packageJsonPath, packageData);
return packageData.name;
} catch (error) {
throw new Error(`Error reading package.json in ${dirent.name}`, error);
}
});
// Separate dependency workspaces and other workspaces
const dependencyWorkspaces = ccFolder.filter((fileName) => dependencies.includes(fileName));

const otherWorkspaces = ccFolder.filter((fileName) => !dependencies.includes(fileName));

const publishWorkspace = (workspaceName) => {
console.log(`Publishing new version for ${workspaceName}: ${newVersion}`);

// Update version in the workspace
execSync(`yarn workspace ${workspaceName} version ${newVersion}`, {stdio: 'inherit'});

// Publish the package
execSync(`yarn workspace ${workspaceName} npm publish --tag ${branchName}`, {stdio: 'inherit'});
};

// Publish dependencies first
dependencyWorkspaces.forEach(publishWorkspace);

// Publish other packages
otherWorkspaces.forEach(publishWorkspace);
} catch (error) {
console.error(`Failed to process workspaces:`, error.message);
process.exit(1);
}
}

// Only execute when called through a module/script
if (require.main !== module) {
// Export the function for testing
module.exports = {versionAndPublish};
} else {
versionAndPublish();
}
Loading