Skip to content

Commit bf9f38e

Browse files
committed
add release script
1 parent 74405ea commit bf9f38e

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

.github/scripts/set-version-bump.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const fs = require( 'fs' );
2+
const path = require( 'path' );
3+
const semver = require( 'semver' );
4+
const packagefile = path.resolve( __dirname, '../../package.json' );
5+
const pluginfile = path.resolve( __dirname, '../../bootstrap.php' );
6+
7+
if ( fs.existsSync( packagefile ) && fs.existsSync( pluginfile ) ) {
8+
const packageData = require( packagefile );
9+
const currentVersion = packageData.version;
10+
let type = process.argv[ 2 ];
11+
if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) {
12+
type = 'patch';
13+
}
14+
15+
const newVersion = semver.inc( packageData.version, type );
16+
packageData.version = newVersion;
17+
fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 4 ) );
18+
19+
fs.readFile( pluginfile, 'utf8', function ( err, data ) {
20+
if ( err ) {
21+
return console.log( err );
22+
}
23+
const result = data.replaceAll( currentVersion, newVersion );
24+
25+
fs.writeFile( pluginfile, result, 'utf8', function ( err ) {
26+
if ( err ) {
27+
return console.log( err );
28+
}
29+
} );
30+
} );
31+
32+
console.log( 'Version updated', currentVersion, '=>', newVersion );
33+
}

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,22 @@ The Onboarding module is designed to streamline various tasks related to user on
9393
- **Conduct thorough testing to ensure stability and functionality.**
9494
- Note any issues or concerns for further action.
9595

96-
4. **Increment version following Semantic Versioning 2.0.0:**
97-
- Update version in:
98-
- `bootstrap.php`
99-
- `package.json`
100-
- `package-lock.json`
101-
- Run:
102-
```bash
103-
npm install
104-
npm run build
105-
```
106-
- Verify existence of `build/<new_version>` folder.
96+
4. **Increment Version via script**
97+
- run `npm run set-version-bump`
98+
- This will update the version number in required files, remove the old build, and create a fresh build.
99+
- Alternatively, update versions and rebuild manually:
100+
1. **Increment version following Semantic Versioning 2.0.0:**
101+
- Update version in:
102+
- `bootstrap.php`
103+
- `package.json`
104+
- `package-lock.json`
105+
- Run:
106+
```bash
107+
npm install
108+
npm run build
109+
```
110+
- Verify existence of `build/<new_version>` folder.
111+
- Update language files. Run: `composer run i18n`.
107112

108113
5. **Push changes to origin:**
109114
```bash

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
"axe-core": "^4.8.3",
1818
"cypress": "^13.6.1",
1919
"cypress-axe": "^1.5.0",
20+
"node-fetch": "^3.3.2",
2021
"webpack-merge": "^5.8.0"
2122
},
2223
"scripts": {
2324
"build": "wp-scripts build ./src/onboarding.js ./src/Scripts/sitegen-theme-marker/sitegen-theme-marker.js ./src/Scripts/sitegen-theme-marker/sitegen-theme-marker.css",
2425
"format": "wp-scripts format ./src",
2526
"start": "wp-scripts start ./src/onboarding.js ./src/Scripts/sitegen-theme-marker/sitegen-theme-marker.js ./src/Scripts/sitegen-theme-marker/sitegen-theme-marker.css",
27+
"set-version-bump": "node ./.github/scripts/set-version-bump.js && npm i && rm -rf ./build && npm run build && composer run i18n",
2628
"lint:js": "wp-scripts lint-js ./src",
2729
"lint:js:fix": "wp-scripts lint-js ./src --fix",
2830
"test:e2e": "npx cypress run",

0 commit comments

Comments
 (0)