From e61f10c26b509b9b975d2f7d8000d08e44e824a5 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 18:29:52 +0530 Subject: [PATCH 01/32] added Jenkins file --- .npmrc | 0 Jenkinsfile | 114 ++++++++++++++++++ core/package.json | 4 +- ....timestamp-1730223298821-ceb3232dc5a83.mjs | 40 ------ 4 files changed, 116 insertions(+), 42 deletions(-) create mode 100644 .npmrc create mode 100644 Jenkinsfile delete mode 100644 core/vite.config.js.timestamp-1730223298821-ceb3232dc5a83.mjs diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e69de29 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..0a5e6b3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,114 @@ +pipeline { + agent any + + environment { + NODE_ENV = 'production' + NPM_TOKEN = credentials('NPM_TOKEN') + GITHUB_TOKEN = credentials('GITHUB_TOKEN') + SLACK_WEBHOOK = credentials('SLACK_WEBHOOK_URL') + REPO = 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs' // πŸ” Replace with your actual repo + } + + tools { + nodejs 'Node_18' + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Install & Build SDK') { + steps { + dir('core') { + sh 'npm ci' + sh 'npm run build' + } + } + } + + stage('Publish to npm') { + steps { + dir('core') { + sh 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' + sh 'npm publish' + } + } + } + + stage('Tag & GitHub Release') { + steps { + dir('core') { + script { + def version = sh(script: "node -p \"require('./package.json').version\"", returnStdout: true).trim() + def tagName = "v${version}" + def releaseName = "Release ${version}" + + sh "git config user.name 'CI Bot'" + sh "git config user.email 'ci@yourdomain.com'" + sh "git tag ${tagName}" + sh "git push origin ${tagName}" + + sh """ + curl -X POST https://api.github.com/repos/${env.REPO}/releases \\ + -H "Authorization: token ${env.GITHUB_TOKEN}" \\ + -H "Content-Type: application/json" \\ + -d '{ + "tag_name": "${tagName}", + "name": "${releaseName}", + "body": "Automated release from Jenkins.", + "draft": false, + "prerelease": false + }' + """ + } + } + } + } + } + + post { + success { + script { + def version = sh(script: "node -p \"require('./core/package.json').version\"", returnStdout: true).trim() + def tagName = "v${version}" + def buildNumber = env.BUILD_NUMBER + def jobName = env.JOB_NAME + def branch = env.GIT_BRANCH ?: 'master' // fallback if not set + def repo = env.REPO + + def slackMessage = """ + { + "attachments": [ + { + "color": "#36a64f", + "title": "βœ… ReactJS SDK Deployed!", + "text": "A new version of the SDK was deployed successfully to npm and GitHub.", + "fields": [ + { "title": "Version", "value": "${tagName}", "short": true }, + { "title": "Branch", "value": "${branch}", "short": true }, + { "title": "Build", "value": "#${buildNumber}", "short": true }, + { "title": "Job", "value": "${jobName}", "short": true } + ], + "footer": "Jenkins CI Β· GitHub Β· npm", + "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", + "ts": ${System.currentTimeMillis() / 1000} + } + ] + } + """ + + sh """ + curl -X POST -H 'Content-type: application/json' \ + --data '${slackMessage}' ${SLACK_WEBHOOK} + """ + echo 'βœ… Fancy Slack notification sent.' + } + } + failure { + echo 'πŸ’₯ Pipeline failed. Slack message skipped.' + } + } +} diff --git a/core/package.json b/core/package.json index f8f222b..cb8d578 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { - "name": "@likeminds.community/likeminds-feed-reactjs", - "version": "1.10.0", + "name": "@likeminds.community/likeminds-feed-reactjs-beta", + "version": "2.2.0", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", diff --git a/core/vite.config.js.timestamp-1730223298821-ceb3232dc5a83.mjs b/core/vite.config.js.timestamp-1730223298821-ceb3232dc5a83.mjs deleted file mode 100644 index 08ffd72..0000000 --- a/core/vite.config.js.timestamp-1730223298821-ceb3232dc5a83.mjs +++ /dev/null @@ -1,40 +0,0 @@ -// vite.config.js -import { resolve } from "path"; -import { defineConfig } from "file:///Users/omen/likeminds-feed-reactjs/core/node_modules/vite/dist/node/index.js"; -import react from "file:///Users/omen/likeminds-feed-reactjs/core/node_modules/@vitejs/plugin-react/dist/index.mjs"; -import dts from "file:///Users/omen/likeminds-feed-reactjs/core/node_modules/vite-plugin-dts/dist/index.mjs"; -import { libInjectCss } from "file:///Users/omen/likeminds-feed-reactjs/core/node_modules/vite-plugin-lib-inject-css/dist/index.js"; -var __vite_injected_original_dirname = "/Users/omen/likeminds-feed-reactjs/core"; -var vite_config_default = defineConfig({ - plugins: [react(), libInjectCss({}), dts({ include: ["src"] })], - build: { - cssCodeSplit: true, - copyPublicDir: false, - lib: { - // Could also be a dictionary or array of multiple entry points - entry: resolve(__vite_injected_original_dirname, "src/index.ts"), - name: "react-feed-lib", - // the proper extensions will be added - fileName: "index" - }, - rollupOptions: { - // make sure to externalize deps that shouldn't be bundled - // into your library - external: ["react", "react-dom", "vite"], - output: { - // Provide global variables to use in the UMD build - // for externalized deps - globals: { - react: "React" - } - } - } - }, - optimizeDeps: { - disabled: false - } -}); -export { - vite_config_default as default -}; -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvb21lbi9saWtlbWluZHMtZmVlZC1yZWFjdGpzL2NvcmVcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9vbWVuL2xpa2VtaW5kcy1mZWVkLXJlYWN0anMvY29yZS92aXRlLmNvbmZpZy5qc1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvb21lbi9saWtlbWluZHMtZmVlZC1yZWFjdGpzL2NvcmUvdml0ZS5jb25maWcuanNcIjsvKiBlc2xpbnQtZGlzYWJsZSBuby11bmRlZiAqL1xuLy8gdml0ZS5jb25maWcuanNcbmltcG9ydCB7IHJlc29sdmUgfSBmcm9tICdwYXRoJ1xuaW1wb3J0IHsgZGVmaW5lQ29uZmlnIH0gZnJvbSAndml0ZSdcbi8vIGltcG9ydCBzY3NzIGZyb20gJ3JvbGx1cC1wbHVnaW4tc2NzcydcbmltcG9ydCByZWFjdCBmcm9tICdAdml0ZWpzL3BsdWdpbi1yZWFjdCdcbmltcG9ydCBkdHMgZnJvbSAndml0ZS1wbHVnaW4tZHRzJ1xuaW1wb3J0IHsgbGliSW5qZWN0Q3NzIH0gZnJvbSAndml0ZS1wbHVnaW4tbGliLWluamVjdC1jc3MnXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuICAgIHBsdWdpbnM6IFtyZWFjdCgpLCBsaWJJbmplY3RDc3Moe1xuXG4gICAgfSksIGR0cyh7IGluY2x1ZGU6IFsnc3JjJ10gfSldLFxuICAgIGJ1aWxkOiB7XG4gICAgICAgIGNzc0NvZGVTcGxpdDogdHJ1ZSxcbiAgICAgICAgY29weVB1YmxpY0RpcjogZmFsc2UsXG4gICAgICAgIGxpYjoge1xuICAgICAgICAgICAgLy8gQ291bGQgYWxzbyBiZSBhIGRpY3Rpb25hcnkgb3IgYXJyYXkgb2YgbXVsdGlwbGUgZW50cnkgcG9pbnRzXG4gICAgICAgICAgICBlbnRyeTogcmVzb2x2ZShfX2Rpcm5hbWUsICdzcmMvaW5kZXgudHMnKSxcbiAgICAgICAgICAgIG5hbWU6ICdyZWFjdC1mZWVkLWxpYicsXG4gICAgICAgICAgICAvLyB0aGUgcHJvcGVyIGV4dGVuc2lvbnMgd2lsbCBiZSBhZGRlZFxuICAgICAgICAgICAgZmlsZU5hbWU6ICdpbmRleCcsXG4gICAgICAgIH0sXG4gICAgICAgIHJvbGx1cE9wdGlvbnM6IHtcbiAgICAgICAgICAgIC8vIG1ha2Ugc3VyZSB0byBleHRlcm5hbGl6ZSBkZXBzIHRoYXQgc2hvdWxkbid0IGJlIGJ1bmRsZWRcbiAgICAgICAgICAgIC8vIGludG8geW91ciBsaWJyYXJ5XG4gICAgICAgICAgICBleHRlcm5hbDogWydyZWFjdCcsICdyZWFjdC1kb20nLCAndml0ZSddLFxuICAgICAgICAgICAgb3V0cHV0OiB7XG4gICAgICAgICAgICAgICAgLy8gUHJvdmlkZSBnbG9iYWwgdmFyaWFibGVzIHRvIHVzZSBpbiB0aGUgVU1EIGJ1aWxkXG4gICAgICAgICAgICAgICAgLy8gZm9yIGV4dGVybmFsaXplZCBkZXBzXG4gICAgICAgICAgICAgICAgZ2xvYmFsczoge1xuICAgICAgICAgICAgICAgICAgICByZWFjdDogJ1JlYWN0JyxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcblxuICAgIH0sXG4gICAgb3B0aW1pemVEZXBzOiB7XG4gICAgICAgIGRpc2FibGVkOiBmYWxzZSxcbiAgICB9LFxuXG59KSJdLAogICJtYXBwaW5ncyI6ICI7QUFFQSxTQUFTLGVBQWU7QUFDeEIsU0FBUyxvQkFBb0I7QUFFN0IsT0FBTyxXQUFXO0FBQ2xCLE9BQU8sU0FBUztBQUNoQixTQUFTLG9CQUFvQjtBQVA3QixJQUFNLG1DQUFtQztBQVF6QyxJQUFPLHNCQUFRLGFBQWE7QUFBQSxFQUN4QixTQUFTLENBQUMsTUFBTSxHQUFHLGFBQWEsQ0FFaEMsQ0FBQyxHQUFHLElBQUksRUFBRSxTQUFTLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztBQUFBLEVBQzdCLE9BQU87QUFBQSxJQUNILGNBQWM7QUFBQSxJQUNkLGVBQWU7QUFBQSxJQUNmLEtBQUs7QUFBQTtBQUFBLE1BRUQsT0FBTyxRQUFRLGtDQUFXLGNBQWM7QUFBQSxNQUN4QyxNQUFNO0FBQUE7QUFBQSxNQUVOLFVBQVU7QUFBQSxJQUNkO0FBQUEsSUFDQSxlQUFlO0FBQUE7QUFBQTtBQUFBLE1BR1gsVUFBVSxDQUFDLFNBQVMsYUFBYSxNQUFNO0FBQUEsTUFDdkMsUUFBUTtBQUFBO0FBQUE7QUFBQSxRQUdKLFNBQVM7QUFBQSxVQUNMLE9BQU87QUFBQSxRQUNYO0FBQUEsTUFDSjtBQUFBLElBQ0o7QUFBQSxFQUVKO0FBQUEsRUFDQSxjQUFjO0FBQUEsSUFDVixVQUFVO0FBQUEsRUFDZDtBQUVKLENBQUM7IiwKICAibmFtZXMiOiBbXQp9Cg== From b8e2732ccadc8606bd477f03fcee5ecb7f866012 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 18:39:31 +0530 Subject: [PATCH 02/32] changes in Jenkinfiles --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0a5e6b3..d349851 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { stage('Install & Build SDK') { steps { dir('core') { - sh 'npm ci' + sh 'npm install --legacy-peer-deps' sh 'npm run build' } } From e73a847257262575f83b7cde81d1afdd93d7fff7 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 18:46:45 +0530 Subject: [PATCH 03/32] changes in Jenkinfiles --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d349851..6918df3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ pipeline { steps { dir('core') { sh 'npm install --legacy-peer-deps' - sh 'npm run build' + sh 'npm run build-lib' } } } From e27b645c7f417bbffed716f5690328991c512838 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 18:59:26 +0530 Subject: [PATCH 04/32] changes in Jenkinfiles --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 6918df3..67a1938 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { NODE_ENV = 'production' + HUSKY = '0' // <-- disables husky in CI NPM_TOKEN = credentials('NPM_TOKEN') GITHUB_TOKEN = credentials('GITHUB_TOKEN') SLACK_WEBHOOK = credentials('SLACK_WEBHOOK_URL') From c0e6f31b619f7081884c26f4fe0009f2e747fbfa Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 19:01:35 +0530 Subject: [PATCH 05/32] changes in Jenkinfiles --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 67a1938..603f6ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,8 +2,6 @@ pipeline { agent any environment { - NODE_ENV = 'production' - HUSKY = '0' // <-- disables husky in CI NPM_TOKEN = credentials('NPM_TOKEN') GITHUB_TOKEN = credentials('GITHUB_TOKEN') SLACK_WEBHOOK = credentials('SLACK_WEBHOOK_URL') From 601ff38077003d01c2ca04dbe07b5b5cb3ba664b Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 19:32:09 +0530 Subject: [PATCH 06/32] changes in Jenkinfiles after git 404 --- Jenkinsfile | 87 +++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 603f6ed..bd55b58 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,10 +2,10 @@ pipeline { agent any environment { + NODE_ENV = 'development' // Don’t set to production to allow dev deps NPM_TOKEN = credentials('NPM_TOKEN') - GITHUB_TOKEN = credentials('GITHUB_TOKEN') SLACK_WEBHOOK = credentials('SLACK_WEBHOOK_URL') - REPO = 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs' // πŸ” Replace with your actual repo + REPO = 'LikeMindsCommunity/likeminds-feed-reactjs' } tools { @@ -46,22 +46,28 @@ pipeline { def releaseName = "Release ${version}" sh "git config user.name 'CI Bot'" - sh "git config user.email 'ci@yourdomain.com'" + sh "git config user.email 'ci@likeminds.community'" sh "git tag ${tagName}" sh "git push origin ${tagName}" - sh """ - curl -X POST https://api.github.com/repos/${env.REPO}/releases \\ - -H "Authorization: token ${env.GITHUB_TOKEN}" \\ - -H "Content-Type: application/json" \\ - -d '{ - "tag_name": "${tagName}", - "name": "${releaseName}", - "body": "Automated release from Jenkins.", - "draft": false, - "prerelease": false - }' - """ + // Securely call GitHub API using credentials block + withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { + sh """ + curl -s -X POST https://api.github.com/repos/${REPO}/releases \\ + -H "Authorization: token \$GITHUB_TOKEN" \\ + -H "Content-Type: application/json" \\ + -d '{ + "tag_name": "${tagName}", + "name": "${releaseName}", + "body": "Automated release from Jenkins.", + "draft": false, + "prerelease": false + }' + """ + } + + // Save version for Slack use + currentBuild.description = tagName } } } @@ -71,43 +77,40 @@ pipeline { post { success { script { - def version = sh(script: "node -p \"require('./core/package.json').version\"", returnStdout: true).trim() - def tagName = "v${version}" + def version = currentBuild.description ?: 'v?' + def branch = env.GIT_BRANCH ?: 'custom' def buildNumber = env.BUILD_NUMBER def jobName = env.JOB_NAME - def branch = env.GIT_BRANCH ?: 'master' // fallback if not set - def repo = env.REPO def slackMessage = """ + { + "attachments": [ { - "attachments": [ - { - "color": "#36a64f", - "title": "βœ… ReactJS SDK Deployed!", - "text": "A new version of the SDK was deployed successfully to npm and GitHub.", - "fields": [ - { "title": "Version", "value": "${tagName}", "short": true }, - { "title": "Branch", "value": "${branch}", "short": true }, - { "title": "Build", "value": "#${buildNumber}", "short": true }, - { "title": "Job", "value": "${jobName}", "short": true } - ], - "footer": "Jenkins CI Β· GitHub Β· npm", - "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", - "ts": ${System.currentTimeMillis() / 1000} - } - ] + "color": "#36a64f", + "title": "βœ… ReactJS SDK Deployed", + "title_link": "https://github.com/${REPO}/releases/tag/${version}", + "text": "A new version of the React SDK has been deployed and released.", + "fields": [ + { "title": "Version", "value": "${version}", "short": true }, + { "title": "Branch", "value": "${branch}", "short": true }, + { "title": "Build", "value": "#${buildNumber}", "short": true } + ], + "footer": "Jenkins CI", + "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", + "ts": ${System.currentTimeMillis() / 1000} } - """ - + ] + } + """ sh """ - curl -X POST -H 'Content-type: application/json' \ - --data '${slackMessage}' ${SLACK_WEBHOOK} - """ - echo 'βœ… Fancy Slack notification sent.' + curl -X POST -H 'Content-type: application/json' \ + --data '${slackMessage}' ${SLACK_WEBHOOK} + """ } } + failure { - echo 'πŸ’₯ Pipeline failed. Slack message skipped.' + echo 'πŸ’₯ Pipeline failed. No release or Slack message.' } } } From e983a1f2a8a553f40db7fa760a66613313d379c9 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 19:32:25 +0530 Subject: [PATCH 07/32] version update --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index cb8d578..708ad85 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.0", + "version": "2.2.1", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From 94abebca6d49217e9d972357d68ffa0743d3ab6e Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Tue, 22 Apr 2025 19:54:11 +0530 Subject: [PATCH 08/32] changes in Jenkinfiles after git 404 --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bd55b58..ae95ef9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,8 +45,8 @@ pipeline { def tagName = "v${version}" def releaseName = "Release ${version}" - sh "git config user.name 'CI Bot'" - sh "git config user.email 'ci@likeminds.community'" + sh "git config user.name 'Ishaan Jain'" + sh "git config user.email 'ishaan.jain@likeminds.community'" sh "git tag ${tagName}" sh "git push origin ${tagName}" @@ -59,7 +59,7 @@ pipeline { -d '{ "tag_name": "${tagName}", "name": "${releaseName}", - "body": "Automated release from Jenkins.", + "generate_release_notes": true, "draft": false, "prerelease": false }' @@ -94,6 +94,7 @@ pipeline { { "title": "Version", "value": "${version}", "short": true }, { "title": "Branch", "value": "${branch}", "short": true }, { "title": "Build", "value": "#${buildNumber}", "short": true } + { "title": "Job Name", "value": "#${jobName}", "short": true } ], "footer": "Jenkins CI", "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", From 5a5f5ed91e8b52b2acc9fcf316eb83671296a59b Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 18:52:15 +0530 Subject: [PATCH 09/32] chore: updated creds as per prod jenkins --- Jenkinsfile | 60 +++++++++++++++++++++++------------------------ core/package.json | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ae95ef9..11063ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,8 @@ pipeline { environment { NODE_ENV = 'development' // Don’t set to production to allow dev deps - NPM_TOKEN = credentials('NPM_TOKEN') - SLACK_WEBHOOK = credentials('SLACK_WEBHOOK_URL') + NPM_TOKEN = credentials('ISHAAN_NPM_TOKEN') + SLACK_WEBHOOK = credentials('SLACK_JS_CHANNEL_URL') REPO = 'LikeMindsCommunity/likeminds-feed-reactjs' } @@ -51,19 +51,19 @@ pipeline { sh "git push origin ${tagName}" // Securely call GitHub API using credentials block - withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { + withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { sh """ curl -s -X POST https://api.github.com/repos/${REPO}/releases \\ -H "Authorization: token \$GITHUB_TOKEN" \\ -H "Content-Type: application/json" \\ -d '{ - "tag_name": "${tagName}", - "name": "${releaseName}", + "tag_name": "${tagName}", + "name": "${releaseName}", "generate_release_notes": true, - "draft": false, - "prerelease": false + "draft": false, + "prerelease": false }' - """ + """ } // Save version for Slack use @@ -84,29 +84,29 @@ pipeline { def slackMessage = """ { - "attachments": [ - { - "color": "#36a64f", - "title": "βœ… ReactJS SDK Deployed", - "title_link": "https://github.com/${REPO}/releases/tag/${version}", - "text": "A new version of the React SDK has been deployed and released.", - "fields": [ - { "title": "Version", "value": "${version}", "short": true }, - { "title": "Branch", "value": "${branch}", "short": true }, - { "title": "Build", "value": "#${buildNumber}", "short": true } - { "title": "Job Name", "value": "#${jobName}", "short": true } - ], - "footer": "Jenkins CI", - "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", - "ts": ${System.currentTimeMillis() / 1000} + "attachments": [ + { + "color": "#36a64f", + "title": "βœ… ReactJS SDK Deployed", + "title_link": "https://github.com/${REPO}/releases/tag/${version}", + "text": "A new version of the React SDK has been deployed and released.", + "fields": [ + { "title": "Version", "value": "${version}", "short": true }, + { "title": "Branch", "value": "${branch}", "short": true }, + { "title": "Build", "value": "#${buildNumber}", "short": true } + { "title": "Job Name", "value": "#${jobName}", "short": true } + ], + "footer": "Jenkins CI", + "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", + "ts": ${System.currentTimeMillis() / 1000} + } + ] } - ] - } - """ - sh """ - curl -X POST -H 'Content-type: application/json' \ - --data '${slackMessage}' ${SLACK_WEBHOOK} - """ + """ + sh """ + curl -X POST -H 'Content-type: application/json' \ + --data '${slackMessage}' ${SLACK_WEBHOOK} + """ } } diff --git a/core/package.json b/core/package.json index 708ad85..f891dc0 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.1", + "version": "2.2.2", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From e473ba4040a079e4e1f3e38f8b32d7b5cd407f1c Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:03:29 +0530 Subject: [PATCH 10/32] chore: updated creds as per prod jenkins --- Jenkinsfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 11063ae..a5ed2f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,9 +13,18 @@ pipeline { } stages { - stage('Checkout') { + stage('Checkout Specific Branch') { steps { - checkout scm + script { + def branchToCheckout = 'feature/LM-13590_createJenkinsPipeline' // ⬅️ Change this to whatever branch you want + checkout([ + $class: 'GitSCM', + branches: [[name: "*/${branchToCheckout}"]], + userRemoteConfigs: [[ + url: 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs.git' + ]] + ]) + } } } @@ -101,7 +110,7 @@ pipeline { "ts": ${System.currentTimeMillis() / 1000} } ] - } + } """ sh """ curl -X POST -H 'Content-type: application/json' \ From 56caf699e91d881271b914cf1659730f4dc5202c Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:08:58 +0530 Subject: [PATCH 11/32] chore: updated creds as per prod jenkins --- Jenkinsfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a5ed2f5..3b63c9b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,10 @@ pipeline { agent any + parameters { + string(name: 'BRANCH_TO_BUILD', defaultValue: 'feature/LM-13590_createJenkinsPipeline', description: 'Branch to checkout and build') + } + environment { NODE_ENV = 'development' // Don’t set to production to allow dev deps NPM_TOKEN = credentials('ISHAAN_NPM_TOKEN') @@ -16,14 +20,14 @@ pipeline { stage('Checkout Specific Branch') { steps { script { - def branchToCheckout = 'feature/LM-13590_createJenkinsPipeline' // ⬅️ Change this to whatever branch you want + def branchToCheckout = params.BRANCH_TO_BUILD ?: 'feature/LM-13590_createJenkinsPipeline' checkout([ - $class: 'GitSCM', - branches: [[name: "*/${branchToCheckout}"]], - userRemoteConfigs: [[ - url: 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs.git' - ]] - ]) + $class: 'GitSCM', + branches: [[name: "*/${branchToCheckout}"]], + userRemoteConfigs: [[ + url: 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs.git' + ]] + ]) } } } From 30cbb21dcbe2433be47398173e1b05ad5ae6366b Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:10:30 +0530 Subject: [PATCH 12/32] chore: updated creds as per prod jenkins --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b63c9b..a6c6bb6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { def branchToCheckout = params.BRANCH_TO_BUILD ?: 'feature/LM-13590_createJenkinsPipeline' checkout([ $class: 'GitSCM', - branches: [[name: "*/${branchToCheckout}"]], + branches: [[name: "refs/heads/${branchToCheckout}"]] userRemoteConfigs: [[ url: 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs.git' ]] From b0966b313c68811565a0939fd16bc2dd606c7953 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:13:27 +0530 Subject: [PATCH 13/32] chore: updated creds as per prod jenkins --- Jenkinsfile | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a6c6bb6..eec87d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,6 @@ pipeline { agent any - parameters { - string(name: 'BRANCH_TO_BUILD', defaultValue: 'feature/LM-13590_createJenkinsPipeline', description: 'Branch to checkout and build') - } - environment { NODE_ENV = 'development' // Don’t set to production to allow dev deps NPM_TOKEN = credentials('ISHAAN_NPM_TOKEN') @@ -17,18 +13,9 @@ pipeline { } stages { - stage('Checkout Specific Branch') { + stage('Checkout') { steps { - script { - def branchToCheckout = params.BRANCH_TO_BUILD ?: 'feature/LM-13590_createJenkinsPipeline' - checkout([ - $class: 'GitSCM', - branches: [[name: "refs/heads/${branchToCheckout}"]] - userRemoteConfigs: [[ - url: 'https://github.com/LikeMindsCommunity/likeminds-feed-reactjs.git' - ]] - ]) - } + checkout scm } } From f9c9726b5ac972f0224c579fdd012986fe60e467 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:16:37 +0530 Subject: [PATCH 14/32] chore: updated jenkinsfile as per node error --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eec87d6..19b7cb3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { } tools { - nodejs 'Node_18' + nodejs 'nodejs' } stages { From 96a912ee66695a84a59adf64e4aed82234de032f Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:44:05 +0530 Subject: [PATCH 15/32] chore: updated jenkinsfile as per git error --- Jenkinsfile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19b7cb3..0eea9ff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,25 +45,25 @@ pipeline { def tagName = "v${version}" def releaseName = "Release ${version}" - sh "git config user.name 'Ishaan Jain'" - sh "git config user.email 'ishaan.jain@likeminds.community'" - sh "git tag ${tagName}" - sh "git push origin ${tagName}" - - // Securely call GitHub API using credentials block - withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { + withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { sh """ - curl -s -X POST https://api.github.com/repos/${REPO}/releases \\ - -H "Authorization: token \$GITHUB_TOKEN" \\ - -H "Content-Type: application/json" \\ - -d '{ - "tag_name": "${tagName}", - "name": "${releaseName}", - "generate_release_notes": true, - "draft": false, - "prerelease": false - }' - """ + git config user.name 'CI Bot' + git config user.email 'ci@likeminds.community' + git tag ${tagName} + git remote set-url origin https://${GITHUB_TOKEN}@github.com/${REPO}.git + git push origin ${tagName} + + curl -s -X POST https://api.github.com/repos/${REPO}/releases \\ + -H "Authorization: token \$GITHUB_TOKEN" \\ + -H "Content-Type: application/json" \\ + -d '{ + "tag_name": "${tagName}", + "name": "${releaseName}", + "generate_release_notes": true, + "draft": false, + "prerelease": false + }' + """ } // Save version for Slack use From 4ea8a7ff9a729607646a247857b374548e054c81 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:47:26 +0530 Subject: [PATCH 16/32] chore: updated jenkinsfile as per git error --- Jenkinsfile | 27 +++++++++++++++++++++++++++ core/package.json | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0eea9ff..a89be09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,33 @@ pipeline { } } + stage('Check git tags') { + steps { + dir('core') { + script { + // Fetch all tags from the remote repository + sh 'git fetch --tags' + + // Get the previous version from the last release tag + def previous_version = sh(script: 'git describe --tags --abbrev=0', returnStdout: true).trim() + + // Get the current version from package.json + def current_version = sh(script: "cat package.json | grep '\"version\":' | awk -F'\"' '{print \$4}'", returnStdout: true).trim() + + echo "previous version ${previous_version}, current version ${current_version}" + + // Compare versions + if (previous_version != "v${current_version}") { + echo "Version has changed from ${previous_version} to v${current_version}." + } else { + echo 'Version has not changed.' + error "Stopping the pipeline as the version hasn't changed." + } + } + } + } + } + stage('Install & Build SDK') { steps { dir('core') { diff --git a/core/package.json b/core/package.json index f891dc0..00b577a 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.2", + "version": "2.2.3", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From 95b9ea2b99fe6fb805948af5c0a926e0772eed46 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 19:50:43 +0530 Subject: [PATCH 17/32] chore: updated jenkinsfile as per git token error --- Jenkinsfile | 2 +- core/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a89be09..88e6a7a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,7 +72,7 @@ pipeline { def tagName = "v${version}" def releaseName = "Release ${version}" - withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { + withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { sh """ git config user.name 'CI Bot' git config user.email 'ci@likeminds.community' diff --git a/core/package.json b/core/package.json index 00b577a..4e3cf9c 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.3", + "version": "2.2.4", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From e8b249c2ae1c271bd00905ade9b462650a0138d6 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 20:00:59 +0530 Subject: [PATCH 18/32] chore: updated jenkinsfile as per slack error --- Jenkinsfile | 42 ++++++++++++++++++++++++------------------ core/package.json | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88e6a7a..41701a2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -103,14 +103,16 @@ pipeline { post { success { - script { - def version = currentBuild.description ?: 'v?' - def branch = env.GIT_BRANCH ?: 'custom' - def buildNumber = env.BUILD_NUMBER - def jobName = env.JOB_NAME - - def slackMessage = """ - { + withCredentials([string(credentialsId: 'SLACK_WEBHOOK_URL', variable: 'SLACK_WEBHOOK')]) { + script { + def version = currentBuild.description ?: 'v?' + def branch = env.GIT_BRANCH ?: 'unknown' + def buildNumber = env.BUILD_NUMBER + def jobName = env.JOB_NAME + def timestamp = (System.currentTimeMillis() / 1000).toLong() + + def slackPayload = """ + { "attachments": [ { "color": "#36a64f", @@ -120,25 +122,29 @@ pipeline { "fields": [ { "title": "Version", "value": "${version}", "short": true }, { "title": "Branch", "value": "${branch}", "short": true }, - { "title": "Build", "value": "#${buildNumber}", "short": true } - { "title": "Job Name", "value": "#${jobName}", "short": true } + { "title": "Build", "value": "#${buildNumber}", "short": true }, + { "title": "Job Name", "value": "${jobName}", "short": true } ], "footer": "Jenkins CI", "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", - "ts": ${System.currentTimeMillis() / 1000} + "ts": ${timestamp} } ] - } - """ - sh """ - curl -X POST -H 'Content-type: application/json' \ - --data '${slackMessage}' ${SLACK_WEBHOOK} + } """ + + // Save payload to file (for escaping issues) + writeFile file: 'slack_payload.json', text: slackPayload + + sh ''' + curl -X POST -H "Content-Type: application/json" \ + --data @slack_payload.json $SLACK_WEBHOOK + ''' + } } } - failure { - echo 'πŸ’₯ Pipeline failed. No release or Slack message.' + echo '❌ Pipeline failed. No Slack message.' } } } diff --git a/core/package.json b/core/package.json index 4e3cf9c..0843063 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.4", + "version": "2.2.5", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From bb97e1e7ab23741988dfd59609803dc43e2c8ca7 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:27:00 +0530 Subject: [PATCH 19/32] chore: updated jenkinsfile as per slack error --- Jenkinsfile | 34 +++++++++++++++------------------- core/package.json | 2 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 41701a2..203b03a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -99,19 +99,18 @@ pipeline { } } } - } - post { - success { - withCredentials([string(credentialsId: 'SLACK_WEBHOOK_URL', variable: 'SLACK_WEBHOOK')]) { - script { - def version = currentBuild.description ?: 'v?' - def branch = env.GIT_BRANCH ?: 'unknown' - def buildNumber = env.BUILD_NUMBER - def jobName = env.JOB_NAME - def timestamp = (System.currentTimeMillis() / 1000).toLong() - - def slackPayload = """ + stage('Notify Slack') { + steps { + withCredentials([string(credentialsId: 'SLACK_JS_CHANNEL_URL', variable: 'SLACK_WEBHOOK')]) { + script { + def version = sh(script: "node -p \"require('./core/package.json').version\"", returnStdout: true).trim() + def branch = env.GIT_BRANCH ?: 'unknown' + def buildNumber = env.BUILD_NUMBER + def jobName = env.JOB_NAME + def timestamp = (System.currentTimeMillis() / 1000).toLong() + + def slackPayload = """ { "attachments": [ { @@ -131,20 +130,17 @@ pipeline { } ] } - """ + """ - // Save payload to file (for escaping issues) - writeFile file: 'slack_payload.json', text: slackPayload + writeFile file: 'slack_payload.json', text: slackPayload - sh ''' + sh ''' curl -X POST -H "Content-Type: application/json" \ --data @slack_payload.json $SLACK_WEBHOOK ''' + } } } } - failure { - echo '❌ Pipeline failed. No Slack message.' - } } } diff --git a/core/package.json b/core/package.json index 0843063..b39aa59 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.5", + "version": "2.2.6", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From eabbdb4ae176ed9aec5bdd84f26ca665ccff2f9d Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:33:18 +0530 Subject: [PATCH 20/32] chore: updated jenkinsfile as per toLong error --- Jenkinsfile | 57 ++++++++++++++++++++++++++++++----------------- core/package.json | 2 +- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 203b03a..bf89c5c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,28 +72,43 @@ pipeline { def tagName = "v${version}" def releaseName = "Release ${version}" - withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { - sh """ - git config user.name 'CI Bot' - git config user.email 'ci@likeminds.community' - git tag ${tagName} - git remote set-url origin https://${GITHUB_TOKEN}@github.com/${REPO}.git - git push origin ${tagName} - - curl -s -X POST https://api.github.com/repos/${REPO}/releases \\ - -H "Authorization: token \$GITHUB_TOKEN" \\ - -H "Content-Type: application/json" \\ - -d '{ - "tag_name": "${tagName}", - "name": "${releaseName}", - "generate_release_notes": true, - "draft": false, - "prerelease": false - }' - """ + // Set Git identity and create tag + sh """ + git config user.name 'Ishaan Jain' + git config user.email 'ishaan.jain@likeminds.community' + git tag ${tagName} + """ + + // Create GitHub release and push tag using secure token + withCredentials([string(credentialsId: 'ISHAAN_NPM_TOKEN', variable: 'GITHUB_TOKEN')]) { + // Set remote with token (only in CI scope) + sh ''' + git remote set-url origin https://$GITHUB_TOKEN@github.com/LikeMindsCommunity/likeminds-feed-reactjs.git + git push origin ${tagName} + '''.stripIndent() + + // Write release payload to a file + def releasePayload = """ + { + "tag_name": "${tagName}", + "name": "${releaseName}", + "generate_release_notes": true, + "draft": false, + "prerelease": false + } + """ + writeFile file: 'release_payload.json', text: releasePayload + + // Hit GitHub release API securely + sh ''' + curl -X POST https://api.github.com/repos/LikeMindsCommunity/likeminds-feed-reactjs/releases \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d @release_payload.json + ''' } - // Save version for Slack use + // Save version for Slack or other stages currentBuild.description = tagName } } @@ -108,7 +123,7 @@ pipeline { def branch = env.GIT_BRANCH ?: 'unknown' def buildNumber = env.BUILD_NUMBER def jobName = env.JOB_NAME - def timestamp = (System.currentTimeMillis() / 1000).toLong() + def timestamp = (System.currentTimeMillis() / 1000) def slackPayload = """ { diff --git a/core/package.json b/core/package.json index b39aa59..acb6d21 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.6", + "version": "2.2.7", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From 8a79ad2a2da3ad92fa5e251ea54c42bd4407d6a1 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:44:14 +0530 Subject: [PATCH 21/32] chore: formatting done --- Jenkinsfile | 144 ++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf89c5c..41af5f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,10 +2,10 @@ pipeline { agent any environment { - NODE_ENV = 'development' // Don’t set to production to allow dev deps - NPM_TOKEN = credentials('ISHAAN_NPM_TOKEN') - SLACK_WEBHOOK = credentials('SLACK_JS_CHANNEL_URL') - REPO = 'LikeMindsCommunity/likeminds-feed-reactjs' + NODE_ENV = 'development' // Don’t set to production to allow dev deps + NPM_TOKEN = credentials('ISHAAN_NPM_TOKEN') + SLACK_WEBHOOK = credentials('SLACK_JS_CHANNEL_URL') + REPO = 'LikeMindsCommunity/likeminds-feed-reactjs' } tools { @@ -23,20 +23,22 @@ pipeline { steps { dir('core') { script { - // Fetch all tags from the remote repository sh 'git fetch --tags' - // Get the previous version from the last release tag - def previous_version = sh(script: 'git describe --tags --abbrev=0', returnStdout: true).trim() + def previousVersion = sh( + script: 'git describe --tags --abbrev=0', + returnStdout: true + ).trim() - // Get the current version from package.json - def current_version = sh(script: "cat package.json | grep '\"version\":' | awk -F'\"' '{print \$4}'", returnStdout: true).trim() + def currentVersion = sh( + script: "node -p \"require('./package.json').version\"", + returnStdout: true + ).trim() - echo "previous version ${previous_version}, current version ${current_version}" + echo "Previous version: ${previousVersion}, Current version: v${currentVersion}" - // Compare versions - if (previous_version != "v${current_version}") { - echo "Version has changed from ${previous_version} to v${current_version}." + if (previousVersion != "v${currentVersion}") { + echo "Version has changed from ${previousVersion} to v${currentVersion}." } else { echo 'Version has not changed.' error "Stopping the pipeline as the version hasn't changed." @@ -58,8 +60,10 @@ pipeline { stage('Publish to npm') { steps { dir('core') { - sh 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' - sh 'npm publish' + sh ''' + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + npm publish + ''' } } } @@ -68,47 +72,42 @@ pipeline { steps { dir('core') { script { - def version = sh(script: "node -p \"require('./package.json').version\"", returnStdout: true).trim() - def tagName = "v${version}" + def version = sh(script: "node -p \"require('./package.json').version\"", returnStdout: true).trim() + def tagName = "v${version}" def releaseName = "Release ${version}" - // Set Git identity and create tag - sh """ - git config user.name 'Ishaan Jain' - git config user.email 'ishaan.jain@likeminds.community' - git tag ${tagName} - """ + sh ''' + git config user.name 'Ishaan Jain' + git config user.email 'ishaan.jain@likeminds.community' + ''' + + sh "git tag ${tagName}" - // Create GitHub release and push tag using secure token - withCredentials([string(credentialsId: 'ISHAAN_NPM_TOKEN', variable: 'GITHUB_TOKEN')]) { - // Set remote with token (only in CI scope) + withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { sh ''' - git remote set-url origin https://$GITHUB_TOKEN@github.com/LikeMindsCommunity/likeminds-feed-reactjs.git - git push origin ${tagName} - '''.stripIndent() + git remote set-url origin https://${GITHUB_TOKEN}@github.com/LikeMindsCommunity/likeminds-feed-reactjs.git + git push origin refs/tags/${tagName} + ''' - // Write release payload to a file def releasePayload = """ - { - "tag_name": "${tagName}", - "name": "${releaseName}", - "generate_release_notes": true, - "draft": false, - "prerelease": false - } - """ + { + "tag_name": "${tagName}", + "name": "${releaseName}", + "generate_release_notes": true, + "draft": false, + "prerelease": false + } + """ writeFile file: 'release_payload.json', text: releasePayload - // Hit GitHub release API securely sh ''' - curl -X POST https://api.github.com/repos/LikeMindsCommunity/likeminds-feed-reactjs/releases \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: application/json" \ - -d @release_payload.json - ''' + curl -X POST https://api.github.com/repos/LikeMindsCommunity/likeminds-feed-reactjs/releases \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Content-Type: application/json" \ + -d @release_payload.json + ''' } - // Save version for Slack or other stages currentBuild.description = tagName } } @@ -119,40 +118,39 @@ pipeline { steps { withCredentials([string(credentialsId: 'SLACK_JS_CHANNEL_URL', variable: 'SLACK_WEBHOOK')]) { script { - def version = sh(script: "node -p \"require('./core/package.json').version\"", returnStdout: true).trim() - def branch = env.GIT_BRANCH ?: 'unknown' + def version = sh(script: "node -p \"require('./core/package.json').version\"", returnStdout: true).trim() + def branch = env.GIT_BRANCH ?: 'unknown' def buildNumber = env.BUILD_NUMBER - def jobName = env.JOB_NAME - def timestamp = (System.currentTimeMillis() / 1000) + def jobName = env.JOB_NAME + def timestamp = (System.currentTimeMillis() / 1000) def slackPayload = """ - { - "attachments": [ - { - "color": "#36a64f", - "title": "βœ… ReactJS SDK Deployed", - "title_link": "https://github.com/${REPO}/releases/tag/${version}", - "text": "A new version of the React SDK has been deployed and released.", - "fields": [ - { "title": "Version", "value": "${version}", "short": true }, - { "title": "Branch", "value": "${branch}", "short": true }, - { "title": "Build", "value": "#${buildNumber}", "short": true }, - { "title": "Job Name", "value": "${jobName}", "short": true } - ], - "footer": "Jenkins CI", - "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", - "ts": ${timestamp} - } - ] - } - """ - + { + "attachments": [ + { + "color": "#36a64f", + "title": "βœ… ReactJS SDK Deployed", + "title_link": "https://github.com/${REPO}/releases/tag/${version}", + "text": "A new version of the React SDK has been deployed and released.", + "fields": [ + { "title": "Version", "value": "${version}", "short": true }, + { "title": "Branch", "value": "${branch}", "short": true }, + { "title": "Build", "value": "#${buildNumber}", "short": true }, + { "title": "Job Name", "value": "${jobName}", "short": true } + ], + "footer": "Jenkins CI", + "footer_icon": "https://jenkins.io/images/logos/jenkins/jenkins.png", + "ts": ${timestamp} + } + ] + } + """ writeFile file: 'slack_payload.json', text: slackPayload sh ''' - curl -X POST -H "Content-Type: application/json" \ - --data @slack_payload.json $SLACK_WEBHOOK - ''' + curl -X POST -H "Content-Type: application/json" \ + --data @slack_payload.json $SLACK_WEBHOOK + ''' } } } From 8675de0dc4c83f63b769923a47b6be96deecec65 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:44:50 +0530 Subject: [PATCH 22/32] chore: version increase --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index acb6d21..26a0355 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.7", + "version": "2.2.8", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From bff871c44eab9d563bd5b2d5ba7013d164992de3 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:47:29 +0530 Subject: [PATCH 23/32] chore: git token error fixed --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 41af5f1..31f2c76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -83,7 +83,7 @@ pipeline { sh "git tag ${tagName}" - withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { + withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { sh ''' git remote set-url origin https://${GITHUB_TOKEN}@github.com/LikeMindsCommunity/likeminds-feed-reactjs.git git push origin refs/tags/${tagName} From d62c647e7edde7c72f332226c8e92193f7338ef0 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:48:26 +0530 Subject: [PATCH 24/32] chore: git token error fixed --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 26a0355..287ddd9 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.8", + "version": "2.2.9", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From 055dad3c67995527b2d990b22e088492f412eb57 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:53:05 +0530 Subject: [PATCH 25/32] chore: git token error fixed 2 --- Jenkinsfile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 31f2c76..daaa4a2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,27 +84,28 @@ pipeline { sh "git tag ${tagName}" withCredentials([string(credentialsId: 'ISHAAN_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { - sh ''' - git remote set-url origin https://${GITHUB_TOKEN}@github.com/LikeMindsCommunity/likeminds-feed-reactjs.git - git push origin refs/tags/${tagName} - ''' + writeFile file: 'release_payload.json', text: """ + { + "tag_name": "${tagName}", + "name": "${releaseName}", + "generate_release_notes": true, + "draft": false, + "prerelease": false + } + """ - def releasePayload = """ - { - "tag_name": "${tagName}", - "name": "${releaseName}", - "generate_release_notes": true, - "draft": false, - "prerelease": false - } + // push the tag securely & safely + sh """ + git remote set-url origin https://\$GITHUB_TOKEN@github.com/${REPO}.git + git push origin refs/tags/${tagName} """ - writeFile file: 'release_payload.json', text: releasePayload + // create the GitHub release sh ''' curl -X POST https://api.github.com/repos/LikeMindsCommunity/likeminds-feed-reactjs/releases \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Content-Type: application/json" \ - -d @release_payload.json + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d @release_payload.json ''' } From 8e5dbb78d01f09a8aab5b99b3c366d528c639f97 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 21:53:11 +0530 Subject: [PATCH 26/32] chore: git token error fixed 2 --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 287ddd9..ef19e27 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.9", + "version": "2.2.10", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", From 805721ef742f7cd83a22b1873957997356b97045 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 22:01:15 +0530 Subject: [PATCH 27/32] chore: added pr template --- core/.github/pull_request_template.md | 29 --------------------------- 1 file changed, 29 deletions(-) delete mode 100644 core/.github/pull_request_template.md diff --git a/core/.github/pull_request_template.md b/core/.github/pull_request_template.md deleted file mode 100644 index 23221e6..0000000 --- a/core/.github/pull_request_template.md +++ /dev/null @@ -1,29 +0,0 @@ -## Description - -**Features** - -**Bugs** - -**What kind of change does this PR introduce?** (check at least one) - - - -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] Hotfix (fixes a breaking changes) -- [ ] New Feature (non-breaking change which adds functionality) -- [ ] Other, please describe: - -### Author Checklist - -- [ ] Assignee added -- [ ] Reviewer added -- [ ] Description added -- [ ] Unit test cases added - -### Reviewer Checklist - -- [ ] PR title starts with Jira ticket number prefix -- [ ] If hotfix, Add Hotfix as prefix in PR title -- [ ] Label added -- [ ] Commit messages follows standard format (added, changed, removed, code commented and chore) -- [ ] Description about the Feature/ Bugs added From 2bbd7412138e455117e5315d626210aa254ccea7 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 22:01:53 +0530 Subject: [PATCH 28/32] chore: added pr template --- .github/pull_request_template.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..23221e6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ +## Description + +**Features** + +**Bugs** + +**What kind of change does this PR introduce?** (check at least one) + + + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] Hotfix (fixes a breaking changes) +- [ ] New Feature (non-breaking change which adds functionality) +- [ ] Other, please describe: + +### Author Checklist + +- [ ] Assignee added +- [ ] Reviewer added +- [ ] Description added +- [ ] Unit test cases added + +### Reviewer Checklist + +- [ ] PR title starts with Jira ticket number prefix +- [ ] If hotfix, Add Hotfix as prefix in PR title +- [ ] Label added +- [ ] Commit messages follows standard format (added, changed, removed, code commented and chore) +- [ ] Description about the Feature/ Bugs added From a3b98783dd351d4fd3e40a2b0ec76cad2c591e46 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 22:07:23 +0530 Subject: [PATCH 29/32] chore: versions corrected and increased --- core/package.json | 4 ++-- core/src/shared/getClient.ts | 2 +- qna-feed/package.json | 2 +- social-feed/package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/package.json b/core/package.json index ef19e27..1df1de0 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { - "name": "@likeminds.community/likeminds-feed-reactjs-beta", - "version": "2.2.10", + "name": "@likeminds.community/likeminds-feed-reactjs", + "version": "1.11.0", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", diff --git a/core/src/shared/getClient.ts b/core/src/shared/getClient.ts index e0c1992..516836f 100644 --- a/core/src/shared/getClient.ts +++ b/core/src/shared/getClient.ts @@ -3,7 +3,7 @@ import { LMFeedClient } from "@likeminds.community/feed-js"; export function initiateFeedClient() { const lmFeedClient = LMFeedClient.Builder() .setPlatformCode("rt") - .setVersionCode(21) + .setVersionCode(22) .build(); return lmFeedClient; } diff --git a/qna-feed/package.json b/qna-feed/package.json index 452d4bb..86fc46b 100644 --- a/qna-feed/package.json +++ b/qna-feed/package.json @@ -12,7 +12,7 @@ "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", - "@likeminds.community/likeminds-feed-reactjs": "^1.8.1", + "@likeminds.community/likeminds-feed-reactjs": "^1.11.0", "@mui/icons-material": "^6.0.2", "@mui/material": "^6.0.2", "react": "^18.2.0", diff --git a/social-feed/package.json b/social-feed/package.json index 69b07d0..a9fc334 100644 --- a/social-feed/package.json +++ b/social-feed/package.json @@ -17,7 +17,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^7.3.0", - "@likeminds.community/likeminds-feed-reactjs": "1.10.0" + "@likeminds.community/likeminds-feed-reactjs": "1.11.0" }, "devDependencies": { "@types/react": "^18.0.0", From e69dbb5366f041a3dc4a30cdc0b560023f826bf4 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Wed, 23 Apr 2025 22:16:29 +0530 Subject: [PATCH 30/32] chore: added branch name check --- .github/workflows/branch-check.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/branch-check.yml diff --git a/.github/workflows/branch-check.yml b/.github/workflows/branch-check.yml new file mode 100644 index 0000000..2dd5275 --- /dev/null +++ b/.github/workflows/branch-check.yml @@ -0,0 +1,21 @@ +name: Valid Source Branches + +on: + pull_request: + branches: + - master + +jobs: + validate-source-branch: + name: Validate Source Branch Pattern + runs-on: ubuntu-latest + steps: + - name: Check if source branch is allowed + run: | + echo "πŸ” Checking branch: ${{ github.head_ref }}" + if [[ ! "${{ github.head_ref }}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ && ! "${{ github.head_ref }}" =~ ^hotfix/LM-[0-9]+_[a-zA-Z0-9_-]+$ ]]; then + echo "🚫 Only branches matching 'release/vX.Y.Z' or 'hotfix/LM-12345_description' can be merged into master." + exit 1 + else + echo "βœ… Valid source branch: ${{ github.head_ref }}" + fi From 72551a1c65a997e15d537609fb6ae235245793a0 Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Thu, 24 Apr 2025 16:24:57 +0530 Subject: [PATCH 31/32] fix: slack message and Release name in git --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index daaa4a2..5a775bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,7 +74,7 @@ pipeline { script { def version = sh(script: "node -p \"require('./package.json').version\"", returnStdout: true).trim() def tagName = "v${version}" - def releaseName = "Release ${version}" + def releaseName = "v${version}" sh ''' git config user.name 'Ishaan Jain' @@ -130,7 +130,7 @@ pipeline { "attachments": [ { "color": "#36a64f", - "title": "βœ… ReactJS SDK Deployed", + "title": "βœ… ReactJS Feed Core SDK Deployed", "title_link": "https://github.com/${REPO}/releases/tag/${version}", "text": "A new version of the React SDK has been deployed and released.", "fields": [ From 666e520847ca1020f6de89a6799f5acd206e269b Mon Sep 17 00:00:00 2001 From: Ishaan Jain Date: Thu, 24 Apr 2025 16:25:48 +0530 Subject: [PATCH 32/32] chore: increased versions --- core/package.json | 2 +- core/src/shared/getClient.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/package.json b/core/package.json index 1df1de0..188fbfd 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@likeminds.community/likeminds-feed-reactjs", - "version": "1.11.0", + "version": "1.11.1", "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", diff --git a/core/src/shared/getClient.ts b/core/src/shared/getClient.ts index 516836f..7742264 100644 --- a/core/src/shared/getClient.ts +++ b/core/src/shared/getClient.ts @@ -3,7 +3,7 @@ import { LMFeedClient } from "@likeminds.community/feed-js"; export function initiateFeedClient() { const lmFeedClient = LMFeedClient.Builder() .setPlatformCode("rt") - .setVersionCode(22) + .setVersionCode(23) .build(); return lmFeedClient; }