Skip to content

Commit

Permalink
Improve release script (#84)
Browse files Browse the repository at this point in the history
* Update release script
* Move from `ts-node` to its modern alternative `tsx`

These changes do not affect our current release process. They make it
easier to perform the existing package release sequence.

Do mind though that the script reports release tag name as
`react-v0.6.x` instead of the old format `v0.6.x-react`. The release
pipeline still expects the latter version, I just haven't made that
change yet. I moved the package discriminator to suffix position so that
pre-release versions of packages have cleaner tags, e.g.
`react-1.2.3-nightly.4`.

### Excerpt from `release.ts`

This script's purpose is to automate the process of publishing a branch
containing new version of a package to the remote repository. It was
written with the goal to maintain a good balance of code brevity,
features, and resilience to errors.

If you had to perform the release manually, you would have to
successfully execute the following steps.
  * Create a release branch or merge code into an already existing one
  * Edit `CHANGELOG.md` to update the release title
  * Bump `"version"` field in `package.json`
  * Commit the changes
  * Push release branch to remote repository

The steps above, except for editing the changelog, could be performed
with following commands.
  ```console
  $ git switch -c release/1.2.x
  <edit CHANGELOG.md>
  $ npm version minor
  $ git commit -m "Release [email protected]" package.json CHANGELOG.md
  $ git push origin HEAD
  ```

That's not a lot. But to account for various (valid and invalid) local
repository states, we need to perform additional checks and actions so
that the desirable result is achieved more consistently and problems are
detected and reported preemptively.

When extending this script, please maintain a couple of core design
guidelines.
* Seek confirmation from the user before making changes to existing
repository state. Changes in branches that this script has just created
are exempt because there's no chance of messing up user's repository.
* Report all observable repository state changes (file writes, commits,
branch operations, etc.)
* Use `throw new RuntimeError(message)` to report error and terminate
script with non-zero status code
  • Loading branch information
roluk authored Jun 27, 2024
1 parent 39f04b5 commit 1de46cf
Show file tree
Hide file tree
Showing 5 changed files with 1,455 additions and 447 deletions.
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,30 @@
"typecheck:client": "npm run typecheck --prefix packages/saved-views-client",
"typecheck:backend": "npm run typecheck --prefix packages/test-app-backend",
"typecheck:frontend": "npm run typecheck --prefix packages/test-app-frontend",
"release": "ts-node --esm scripts/release.ts",
"post-release": "ts-node --esm scripts/post-release.ts"
"release": "tsx scripts/release.ts",
"post-release": "tsx scripts/release.ts -- post-release"
},
"engines": {
"pnpm": ">=8",
"npm": "<0",
"node": ">=18"
},
"dependencies": {
"@commander-js/extra-typings": "^12.1.0",
"@inquirer/prompts": "^5.0.5",
"@types/node": "^18.11.9",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"chalk": "^5.3.0",
"commander": "^12.1.0",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.33.0",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^10.4.1",
"npm-run-all": "^4.1.5",
"ts-node": "^10.9.1",
"semver": "^7.6.2",
"tsx": "^4.15.4",
"typescript": "^5.3.3"
}
}
4 changes: 2 additions & 2 deletions packages/test-app-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://www.bentley.com"
},
"scripts": {
"start": "ts-node-dev --transpile-only --respawn -- src/main.ts",
"start": "tsx watch src/main.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand All @@ -21,7 +21,7 @@
"@types/dotenv-flow": "^3.2.0",
"@types/node": "^18.0.0",
"dotenv-flow": "^3.2.0",
"ts-node-dev": "^2.0.0",
"tsx": "^4.15.4",
"typescript": "^5.3.3"
}
}
Loading

0 comments on commit 1de46cf

Please sign in to comment.