-
Notifications
You must be signed in to change notification settings - Fork 70
feat(release): publish pipeline for wxcc widgets #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f507c5c
10531f7
09e8912
af2a9b8
9dd3461
bb17741
20dfb7a
5daeeea
5d0a65e
445e8a7
7e20bec
7e28d02
3dc6f9f
3e11c58
e01591c
72b6672
25eb283
4b87ffd
1c67f46
eb6561e
604e030
2d612b7
fb2cee0
7a7e976
f36f2bb
a253f02
f348033
bd8d772
e9e310b
50db292
881d71d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ jobs: | |
| root: . | ||
| paths: | ||
| - node_modules | ||
| - packages/*/node_modules | ||
| - packages/**/*/node_modules | ||
|
|
||
| linter: | ||
| executor: node-executor | ||
|
|
@@ -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: | ||
|
|
@@ -87,6 +90,25 @@ jobs: | |
| name: Release | ||
| command: yarn workspace @webex/widgets run release | ||
|
|
||
| unit_tests: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
@@ -98,19 +120,32 @@ workflows: | |
| - build: | ||
| requires: | ||
| - linter | ||
| filters: | ||
| branches: | ||
| only: master | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - docs: | ||
| requires: | ||
| - linter | ||
| filters: | ||
| branches: | ||
| only: master | ||
| only: | ||
| - master | ||
|
|
||
| - unit_tests: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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}" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test:unit will run all the tests.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a suggestion for improvement. We could use |
||
| "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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
|
||
| 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(); | ||
| } |

There was a problem hiding this comment.
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)