Skip to content

Commit 00a3ee3

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Added a script to update the versions.
Signed-off-by: Akos Kitta <[email protected]>
1 parent f1bffaa commit 00a3ee3

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

Diff for: README.md

+32
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,38 @@ This project is built on [GitHub Actions](https://github.com/bcmi-labs/arduino-e
8787
git push origin 1.2.3
8888
```
8989

90+
### Creating a GH release
91+
This section guides you through how to create a new release. Let's assume the current version is `0.1.3` and you want to release `0.2.0`.
92+
93+
- Make sure the `master` state represents what you want to release and you're on `master`.
94+
- Prepare a release-candidate build on a branch:
95+
```bash
96+
git branch 0.2.0-rc \
97+
&& git checkout 0.2.0-rc
98+
```
99+
- Bump up the version number. It must be a valid [semver](https://semver.org/) and must be greater than the current one:
100+
```bash
101+
yarn update:version 0.2.0
102+
```
103+
- This should generate multiple outgoing changes with the version update.
104+
- Commit your changes and push to the remote:
105+
```bash
106+
git add . \
107+
&& git commit -s -m "Updated versions to 0.2.0" \
108+
&& git push
109+
```
110+
- Create the GH PR the workflow starts automatically.
111+
- Once you're happy with the RC, merge the changes to the `master`.
112+
- Create a tag and push it:
113+
```bash
114+
git tag -a 0.2.0 -m "0.2.0" \
115+
&& git push origin 0.2.0
116+
```
117+
- The release build starts automatically and uploads the artifacts with the changelog to the Pro IDE [release page](https://github.com/arduino/arduino-pro-ide/releases).
118+
- If you do not want to release the `EXE` and `MSI` installers, wipe them manually.
119+
- If you do not like the generated changelog, modify it and update the GH release.
120+
121+
90122
### FAQ
91123
92124
- Q: Can I manually change the version of the [`arduino-cli`](https://github.com/arduino/arduino-cli/) used by the IDE?

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"cross-env": "^7.0.2",
1515
"lerna": "^3.20.2",
1616
"rimraf": "^2.6.1",
17+
"semver": "^7.3.2",
1718
"tslint": "^5.5.0",
1819
"typescript": "^3.9.2"
1920
},
@@ -24,7 +25,8 @@
2425
"start": "yarn --cwd ./electron-app start",
2526
"watch": "lerna run watch --parallel",
2627
"test": "lerna run test",
27-
"download:plugins": "theia download:plugins"
28+
"download:plugins": "theia download:plugins",
29+
"update:version": "node ./scripts/update-version.js"
2830
},
2931
"workspaces": [
3032
"arduino-ide-extension",

Diff for: scripts/update-version.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//@ts-check
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const semver = require('semver');
6+
7+
const targetVersion = process.argv.slice(2).shift();
8+
const repoRootPath = path.join(__dirname, '..');
9+
const { version: currentVersion } = require(path.join(repoRootPath, 'package.json'));
10+
11+
if (!targetVersion) {
12+
console.error('Target version was not specified. Target version must be a valid semver. Use: `yarn update:version x.y.z` to update the versions.');
13+
process.exit(1);
14+
}
15+
16+
if (!semver.valid(targetVersion)) {
17+
console.error(`Target version '${targetVersion}' is not a valid semver. Use: \`yarn update:version x.y.z\` to update the versions.`);
18+
process.exit(1);
19+
}
20+
21+
if (!semver.gt(targetVersion, currentVersion)) {
22+
console.error(`Target version '${targetVersion}' must be greater than the current version '${currentVersion}.'`);
23+
process.exit(1);
24+
}
25+
26+
console.log(`🛠️ Updating current version from '${currentVersion}' to '${targetVersion}':`);
27+
for (const toUpdate of [
28+
path.join(repoRootPath, 'package.json'),
29+
path.join(repoRootPath, 'electron-app', 'package.json'),
30+
path.join(repoRootPath, 'browser-app', 'package.json'),
31+
path.join(repoRootPath, 'arduino-ide-extension', 'package.json'),
32+
path.join(repoRootPath, 'arduino-debugger-extension', 'package.json') // Currently unused. The debugger functionality comes from the `cortex.debug` VS Code extension.
33+
]) {
34+
process.stdout.write(` Updating ${toUpdate}'...`);
35+
const pkg = require(toUpdate);
36+
pkg.version = targetVersion;
37+
if ('dependencies' in pkg) {
38+
for (const dep of Object.keys(pkg['dependencies'])) {
39+
if (dep.startsWith('arduino-')) {
40+
pkg['dependencies'][dep] = targetVersion;
41+
}
42+
}
43+
}
44+
fs.writeFileSync(toUpdate, JSON.stringify(pkg, null, 2) + '\n');
45+
process.stdout.write(` ✅ Done.\n`);
46+
}
47+
48+
console.log(`Done. The new version is '${targetVersion}' now. Commit your changes and tag the code for the release. 🚢`);

0 commit comments

Comments
 (0)