Skip to content

Commit

Permalink
feat(config): refactor version update command and improve error handl…
Browse files Browse the repository at this point in the history
…ing in script
  • Loading branch information
IhsenBouallegue committed Dec 13, 2024
1 parent 9419da6 commit f4fba91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
id: version
run: |
set -e # Exit immediately if a command exits with a non-zero status
NEW_VERSION=$(bun script/version-manager.ts ${{ inputs.repository }} ${{ inputs.version_type }})
NEW_VERSION=$(bun script/version-manager.ts update-version ${{ inputs.repository }} ${{ inputs.version_type }})
if [ $? -ne 0 ]; then
echo "::error::Version manager failed"
exit 1
Expand Down
31 changes: 19 additions & 12 deletions script/version-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,25 @@ if (import.meta.main) {
const [command, ...args] = process.argv.slice(2)
const manager = new VersionManager()

if (command === "extract-changelog") {
if (args.length !== 1) {
console.error("Usage: bun script/version-manager.ts extract-changelog <repository>")
process.exit(1)
}
process.stdout.write(manager.extractChangelog(args[0]))
} else {
// existing version update logic
if (args.length !== 2) {
console.error("Usage: bun script/version-manager.ts <repository> <version-type>")
switch (command) {
case "extract-changelog":
if (args.length !== 1) {
console.error("Usage: bun script/version-manager.ts extract-changelog <repository>")
process.exit(1)
}
process.stdout.write(manager.extractChangelog(args[0]))
break

case "update-version":
if (args.length !== 2) {
console.error("Usage: bun script/version-manager.ts update-version <repository> <version-type>")
process.exit(1)
}
process.stdout.write(manager.updateVersion(args[0], args[1]))
break

default:
console.error("Unknown command. Available commands: extract-changelog, update-version")
process.exit(1)
}
process.stdout.write(manager.updateVersion(args[0], args[1]))
}
}

0 comments on commit f4fba91

Please sign in to comment.