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 new file mode 100644 index 0000000..c43f8c8 --- /dev/null +++ b/config-overrides.js @@ -0,0 +1,16 @@ +const { version } = require('./package.json'); + +const [major] = version.split('.'); + +module.exports = function override(config, env) { + 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-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 4bd5c64..f8bee77 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": { @@ -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", @@ -55,10 +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" + "prettier": "^3.1.1", + "react-app-rewired": "^2.2.1", + "semantic-release": "^24.1.2" } }