Skip to content

Commit

Permalink
feat(release): create-release-pipeline (webex#306)
Browse files Browse the repository at this point in the history
Co-authored-by: Shreyas Sharma <shreysh2@cisco.com>
  • Loading branch information
Shreyas281299 and ShreyasSharma28 authored Nov 18, 2024
1 parent 09961ba commit 29bc449
Show file tree
Hide file tree
Showing 13 changed files with 1,497 additions and 60 deletions.
28 changes: 24 additions & 4 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
- 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 @@ -86,6 +89,14 @@ jobs:
- run:
name: Release
command: yarn workspace @webex/widgets run release

release_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:
Expand All @@ -100,17 +111,26 @@ workflows:
- linter
filters:
branches:
only: master
only:
- master
- eft-pipeline
- docs:
requires:
- linter
filters:
branches:
only: master
only:
- master
- release:
requires:
- build
- docs
filters:
branches:
only: master
- release_widgets:
requires:
- build
filters:
branches:
only: eft-pipeline
46 changes: 46 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"branches": [
"master",
{
"name": "eft-pipeline",
"prerelease": "eft-pipeline"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "node publish.js @webex/cc-store eft-pipeline"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "node publish.js @webex/cc-station-login eft-pipeline"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "node publish.js @webex/cc-user-state eft-pipeline"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"package.json",
"packages/contact-center/*/package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
"tagFormat": "${nextRelease.version}"
}
],
"@semantic-release/github"
],
"tagFormat":"${version}"
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
],
"packageManager": "yarn@4.5.1",
"devDependencies": {
"@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",
"node-gyp": "^10.2.0",
"semantic-release": "^24.2.0",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
Expand All @@ -25,6 +30,7 @@
"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"
}
}
13 changes: 11 additions & 2 deletions packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"name": "@webex/cc-station-login",
"description": "Webex Contact Center Widgets: Station Login",
"version": "1.0.0",
"version": "1.28.0-eft-pipeline.3",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
"build:watch": "webpack --watch",
"test:unit": "jest"
"test:unit": "jest",
"release": "echo 'Releasing @webex/cc-station-login' && semantic-release --no-ci && echo 'Released @webex/cc-station-login'"
},
"dependencies": {
"@r2wc/react-to-web-component": "2.0.3",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"@webex/cc-store": "workspace:*",
"mobx-react": "9.1.1",
"react": "18.3.1",
Expand All @@ -32,6 +40,7 @@
"file-loader": "6.2.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"semantic-release": "^24.2.0",
"ts-loader": "9.5.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4",
Expand Down
3 changes: 3 additions & 0 deletions packages/contact-center/station-login/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
* StationLogin helper
*/
export const useStationLogin = () => {
return {name: 'StationLogin'};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export interface IStationLoginProps {
/**
* The name of the station.
*
*/
name: string;

Expand Down
13 changes: 11 additions & 2 deletions packages/contact-center/store/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"name": "@webex/cc-store",
"description": "Webex Contact Center Widgets: Widgets Store",
"version": "1.0.0",
"version": "1.28.0-eft-pipeline.25",
"main": "dist/index.js",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
"build:watch": "webpack --watch",
"test:unit": "jest"
"test:unit": "jest",
"release": "echo 'Releasing @webex/cc-store' && semantic-release --no-ci && echo 'Released @webex/cc-store'"
},
"dependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"mobx": "6.13.5",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand All @@ -31,6 +39,7 @@
"file-loader": "6.2.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"semantic-release": "^24.2.0",
"ts-loader": "9.5.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4",
Expand Down
4 changes: 3 additions & 1 deletion packages/contact-center/store/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {makeAutoObservable, observable} from 'mobx';

import sdk from './sdk';

/*
* Store class
*/
class Store {
loginState = '';
isAvailable = false;
Expand Down
13 changes: 11 additions & 2 deletions packages/contact-center/user-state/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"name": "@webex/cc-user-state",
"description": "Webex Contact Center Widgets: User State",
"version": "1.0.0",
"version": "1.28.0-eft-pipeline.1",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
"build:watch": "webpack --watch",
"test:unit": "jest"
"test:unit": "jest",
"release": "echo 'Releasing @webex/cc-user-state' && semantic-release --no-ci && echo 'Released @webex/cc-user-state'"
},
"dependencies": {
"@r2wc/react-to-web-component": "2.0.3",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"@webex/cc-store": "workspace:*",
"mobx-react": "9.1.1",
"react": "18.3.1",
Expand All @@ -32,6 +40,7 @@
"file-loader": "6.2.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"semantic-release": "^24.2.0",
"ts-loader": "9.5.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/contact-center/user-state/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* UserState helpers
*/

export const useUserState = () => {
return {name: 'UserState'};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React from 'react';

import {IUserState} from './use-state.types';

/**
* Presentational component for the User State.
*/
const UserStatePresentational: React.FunctionComponent<IUserState> = (props) => {
return (
<>
Expand Down
54 changes: 54 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const {execSync} = require('child_process');
const path = require('path');

// Define the versionAndPublish function
function versionAndPublish(workspaceName) {
try {
let version;
const branchName = process.argv[3];

try {
// Fetch the existing version from npm
version = execSync(`npm view ${workspaceName} dist-tags.${branchName}`, {stdio: 'pipe'})
.toString()
.trim();
} catch (npmError) {
// If no package is found (npm view fails), log a message and continue
console.log(`No existing version found for ${workspaceName}. Creating a new version.`);
version = '';
}

let newVersion;
if (!version) {
newVersion = `1.28.0-${branchName}.1`;
} else {
// Increment the patch number
const baseVersion = parseInt(version.split('.').pop(), 10);
newVersion = `1.28.0-${branchName}.${baseVersion + 1}`;
}

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'});
} catch (error) {
console.error(`Failed to process workspace ${workspaceName}:`, error.message);
process.exit(1);
}
}

// Get the workspace name from command-line arguments
const workspaceName = process.argv[2];

if (!workspaceName) {
console.error('Error: Workspace name must be provided!');
process.exit(1);
}

// Call the versionAndPublish function with the workspace name
versionAndPublish(workspaceName);

module.exports = versionAndPublish;
Loading

0 comments on commit 29bc449

Please sign in to comment.