Skip to content

Commit 27c4fae

Browse files
authored
Bump version on release (#134)
1 parent 8a461e9 commit 27c4fae

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ jobs:
1313
registry-url: https://registry.npmjs.org/
1414
- run: npm run bootstrap
1515
- run: npm run build
16+
- run: node scripts/bump-version.js
1617
- run: |
17-
TAG=$(echo $TAG | cut -c1-8)
18-
gh release create "$TAG" \
18+
VERSION=$(node -p "require('./lerna.json').version")
19+
gh release create "$VERSION" \
1920
--repo="$GITHUB_REPOSITORY" \
20-
--title="${TAG#v}" \
21+
--title="${VERSION#v}" \
2122
--generate-notes \
2223
./lib/*.zip
24+
git config --global user.name 'Release'
25+
git config --global user.email 'release@bot.com'
26+
git commit -am "Bump version ($VERSION)"
27+
git push
2328
env:
24-
TAG: ${{ github.event.pull_request.head.sha || github.sha }}
2529
GH_TOKEN: ${{ github.token }}

scripts/bump-version.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const lernaJson = require('../lerna.json');
3+
const mobxDevtools = require('../packages/mobx-devtools/package.json');
4+
const mobxDevtoolsMst = require('../packages/mobx-devtools-mst/package.json');
5+
const playground = require('../packages/playground/package.json');
6+
7+
const [vMajor, vMinor, vPatch] = lernaJson.version.split('.');
8+
9+
const newVersion = `${vMajor}.${vMinor}.${+vPatch + 1}`;
10+
11+
lernaJson.version = newVersion;
12+
13+
fs.writeFileSync('./lerna.json', JSON.stringify(lernaJson, null, 4), 'utf8');
14+
15+
[
16+
[mobxDevtools, './packages/mobx-devtools/package.json'],
17+
[mobxDevtoolsMst, './packages/mobx-devtools-mst/package.json'],
18+
[playground, './packages/playground/package.json'],
19+
].forEach(([pkg, path]) => {
20+
pkg.version = newVersion;
21+
fs.writeFileSync(path, JSON.stringify(pkg, null, 4), 'utf8');
22+
});

0 commit comments

Comments
 (0)