dev(release): fix caching behaviour for version confirmation
Created by: bobheadxi
For a bug noted in https://github.com/sourcegraph/sourcegraph/issues/16207, where providing an invalid version during the confirmation would cause a lot of pains. This change:
- Removes cached version if validation fails
- Improves error messages about release configuration
- Adds a utility command for clearing the cache
Validated new behaviour by failing confirmation a few times before I get it right:
~/Projects/sourcegraph/sourcegraph main* 6s
❯ yarn run release release:status
yarn run v1.22.4
$ cd dev/release && yarn run release release:status
$ ../../node_modules/.bin/ts-node --transpile-only ./src/main.ts release:status
Please confirm the upcoming release version (configured: '3.23.0'): 3.21.0
Error: Provided version '3.21.0' and config.upcomingRelease '3.23.0' to not match - please update the release configuration at 'release-config.jsonc' and try again
~/Projects/sourcegraph/sourcegraph main*
❯ yarn run release release:status
yarn run v1.22.4
$ cd dev/release && yarn run release release:status
$ ../../node_modules/.bin/ts-node --transpile-only ./src/main.ts release:status
Please confirm the upcoming release version (configured: '3.23.0'): 3.22.0
Error: Provided version '3.22.0' and config.upcomingRelease '3.23.0' to not match - please update the release configuration at 'release-config.jsonc' and try again
~/Projects/sourcegraph/sourcegraph main* 7s
❯ yarn run release release:status
yarn run v1.22.4
$ cd dev/release && yarn run release release:status
$ ../../node_modules/.bin/ts-node --transpile-only ./src/main.ts release:status
Please confirm the upcoming release version (configured: '3.23.0'): 3.23.0
Using versions: { upcoming: 3.23.0, previous: 3.22.0 }