From ad8d0f02f77fa514e189bfe2102498d486ef0dc0 Mon Sep 17 00:00:00 2001 From: syam babu Date: Thu, 10 Oct 2024 15:00:55 +0530 Subject: [PATCH 1/3] feat: added config-overrides.js to customize build file names --- config-overrides.js | 9 +++++++++ package.json | 15 ++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 config-overrides.js diff --git a/config-overrides.js b/config-overrides.js new file mode 100644 index 0000000..ccbac56 --- /dev/null +++ b/config-overrides.js @@ -0,0 +1,9 @@ +/* eslint-disable no-undef */ +const { version } = require('./package.json'); +module.exports = function override(config, env) { + if (env === 'production') { + config.output.filename = `static/js/widget-${version}.js`; + config.plugins[5].options.filename = `static/css/widget-${version}.css`; + } + return config; +}; diff --git a/package.json b/package.json index 4bd5c64..5fa4ed7 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,12 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "react-scripts start", - "start:staging": "env-cmd -f .env.staging react-scripts start", - "start:production": "env-cmd -f .env.production react-scripts start", - "build:staging": "env-cmd -f .env.staging react-scripts build", - "build:production": "env-cmd -f .env.production react-scripts build", - "test": "react-scripts test", + "start": "react-app-rewired start", + "start:staging": "env-cmd -f .env.staging react-app-rewired start", + "start:production": "env-cmd -f .env.production react-app-rewired start", + "build:staging": "env-cmd -f .env.staging react-app-rewired build", + "build:production": "env-cmd -f .env.production react-app-rewired build", + "test": "react-app-rewired test", "eject": "react-scripts eject", "lint": "eslint .", "lint:fix": "eslint --fix", @@ -59,6 +59,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.2", "eslint-plugin-react": "^7.33.2", - "prettier": "^3.1.1" + "prettier": "^3.1.1", + "react-app-rewired": "^2.2.1" } } From 65c983c6420e6d35db14a53d70317c3fe5952cd3 Mon Sep 17 00:00:00 2001 From: syam babu Date: Thu, 10 Oct 2024 15:01:41 +0530 Subject: [PATCH 2/3] 0.1.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 60a4dab..0d48fb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "calendar-widget", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "calendar-widget", - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", diff --git a/package.json b/package.json index 5fa4ed7..423e020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calendar-widget", - "version": "0.1.0", + "version": "0.1.1", "private": true, "homepage": ".", "dependencies": { From 9c9958b433e9d082ea642ff1e3286892a039edf5 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 18 Oct 2024 11:56:36 +0530 Subject: [PATCH 3/3] feat: integrated semantic versioning into staging release pipeline. --- .eslintrc.json | 10 +++++++++- .github/workflows/build-staging-deploy-s3.yml | 20 +++++++++++++++++++ .releaserc.json | 10 ++++++++++ config-overrides.js | 15 ++++++++++---- package.json | 6 +++++- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .releaserc.json diff --git a/.eslintrc.json b/.eslintrc.json index e076c52..081a64d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,7 +5,15 @@ "jest": true }, "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"], - "overrides": [], + "overrides": [ + { + "files": ["config-overrides.js", "renameBuildFiles.js"], + "rules": { + "no-undef": "off", + "no-unused-vars": "off" + } + } + ], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" diff --git a/.github/workflows/build-staging-deploy-s3.yml b/.github/workflows/build-staging-deploy-s3.yml index 1defddb..1612228 100644 --- a/.github/workflows/build-staging-deploy-s3.yml +++ b/.github/workflows/build-staging-deploy-s3.yml @@ -4,6 +4,25 @@ on: branches: - develop jobs: + release: + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release deploy: env: AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} @@ -18,3 +37,4 @@ jobs: - run: npm install - run: npm run build:staging - run: aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/ --acl public-read --delete --cache-control max-age=3600 + \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..3444c47 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,10 @@ +{ + "branches": ["main", "develop"], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/git" + ] +} diff --git a/config-overrides.js b/config-overrides.js index ccbac56..c43f8c8 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -1,9 +1,16 @@ -/* eslint-disable no-undef */ const { version } = require('./package.json'); + +const [major] = version.split('.'); + module.exports = function override(config, env) { - if (env === 'production') { - config.output.filename = `static/js/widget-${version}.js`; - config.plugins[5].options.filename = `static/css/widget-${version}.css`; + config.output.filename = `static/js/widget-${major}.js`; + + const miniCssExtractPlugin = config.plugins.find( + (plugin) => plugin.constructor.name === 'MiniCssExtractPlugin', + ); + if (miniCssExtractPlugin) { + miniCssExtractPlugin.options.filename = `static/css/widget-${major}.css`; } + return config; }; diff --git a/package.json b/package.json index 423e020..f8bee77 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,15 @@ ] }, "devDependencies": { + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "@semantic-release/npm": "^12.0.1", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.2", "eslint-plugin-react": "^7.33.2", "prettier": "^3.1.1", - "react-app-rewired": "^2.2.1" + "react-app-rewired": "^2.2.1", + "semantic-release": "^24.1.2" } }