From 00a3ee34c8b3c7a66daf3c206d0aec6403fa8db4 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Mon, 14 Dec 2020 14:13:56 +0100 Subject: [PATCH] Added a script to update the versions. Signed-off-by: Akos Kitta --- README.md | 32 ++++++++++++++++++++++++++ package.json | 4 +++- scripts/update-version.js | 48 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 scripts/update-version.js diff --git a/README.md b/README.md index 0cea3057..9ef975b3 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,38 @@ This project is built on [GitHub Actions](https://github.com/bcmi-labs/arduino-e git push origin 1.2.3 ``` +### Creating a GH release +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`. + + - Make sure the `master` state represents what you want to release and you're on `master`. + - Prepare a release-candidate build on a branch: +```bash +git branch 0.2.0-rc \ +&& git checkout 0.2.0-rc +``` + - Bump up the version number. It must be a valid [semver](https://semver.org/) and must be greater than the current one: +```bash +yarn update:version 0.2.0 +``` + - This should generate multiple outgoing changes with the version update. + - Commit your changes and push to the remote: +```bash +git add . \ +&& git commit -s -m "Updated versions to 0.2.0" \ +&& git push +``` + - Create the GH PR the workflow starts automatically. + - Once you're happy with the RC, merge the changes to the `master`. + - Create a tag and push it: +```bash +git tag -a 0.2.0 -m "0.2.0" \ +&& git push origin 0.2.0 +``` + - 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). + - If you do not want to release the `EXE` and `MSI` installers, wipe them manually. + - If you do not like the generated changelog, modify it and update the GH release. + + ### FAQ - Q: Can I manually change the version of the [`arduino-cli`](https://github.com/arduino/arduino-cli/) used by the IDE? diff --git a/package.json b/package.json index 3c90d299..61a7f40b 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "cross-env": "^7.0.2", "lerna": "^3.20.2", "rimraf": "^2.6.1", + "semver": "^7.3.2", "tslint": "^5.5.0", "typescript": "^3.9.2" }, @@ -24,7 +25,8 @@ "start": "yarn --cwd ./electron-app start", "watch": "lerna run watch --parallel", "test": "lerna run test", - "download:plugins": "theia download:plugins" + "download:plugins": "theia download:plugins", + "update:version": "node ./scripts/update-version.js" }, "workspaces": [ "arduino-ide-extension", diff --git a/scripts/update-version.js b/scripts/update-version.js new file mode 100644 index 00000000..783617a6 --- /dev/null +++ b/scripts/update-version.js @@ -0,0 +1,48 @@ +//@ts-check + +const fs = require('fs'); +const path = require('path'); +const semver = require('semver'); + +const targetVersion = process.argv.slice(2).shift(); +const repoRootPath = path.join(__dirname, '..'); +const { version: currentVersion } = require(path.join(repoRootPath, 'package.json')); + +if (!targetVersion) { + 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.'); + process.exit(1); +} + +if (!semver.valid(targetVersion)) { + console.error(`Target version '${targetVersion}' is not a valid semver. Use: \`yarn update:version x.y.z\` to update the versions.`); + process.exit(1); +} + +if (!semver.gt(targetVersion, currentVersion)) { + console.error(`Target version '${targetVersion}' must be greater than the current version '${currentVersion}.'`); + process.exit(1); +} + +console.log(`🛠️ Updating current version from '${currentVersion}' to '${targetVersion}':`); +for (const toUpdate of [ + path.join(repoRootPath, 'package.json'), + path.join(repoRootPath, 'electron-app', 'package.json'), + path.join(repoRootPath, 'browser-app', 'package.json'), + path.join(repoRootPath, 'arduino-ide-extension', 'package.json'), + path.join(repoRootPath, 'arduino-debugger-extension', 'package.json') // Currently unused. The debugger functionality comes from the `cortex.debug` VS Code extension. +]) { + process.stdout.write(` Updating ${toUpdate}'...`); + const pkg = require(toUpdate); + pkg.version = targetVersion; + if ('dependencies' in pkg) { + for (const dep of Object.keys(pkg['dependencies'])) { + if (dep.startsWith('arduino-')) { + pkg['dependencies'][dep] = targetVersion; + } + } + } + fs.writeFileSync(toUpdate, JSON.stringify(pkg, null, 2) + '\n'); + process.stdout.write(` ✅ Done.\n`); +} + +console.log(`Done. The new version is '${targetVersion}' now. Commit your changes and tag the code for the release. 🚢`);