-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect version increment on publish
- Loading branch information
Showing
4 changed files
with
61 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ActionError } from '@/utils/action'; | ||
|
||
export async function getNextVersion(version: string) { | ||
const parts = version.split('.'); | ||
parts[parts.length - 1] = String(Number(parts[parts.length - 1]) + 1); | ||
return parts.join('.'); | ||
} | ||
|
||
export async function setVersion(version: string) { | ||
const file = await getVersionSource(); | ||
file.content.version = version; | ||
await Bun.write(file.source, JSON.stringify(file.content, null, 2)); | ||
} | ||
|
||
async function getVersionSource() { | ||
const metadata = await Bun.file('./integration.json').json(); | ||
if (metadata.version) { | ||
return { | ||
source: 'integration.json', | ||
content: metadata as { version: string }, | ||
}; | ||
} | ||
|
||
const packageJson = await Bun.file('./package.json').json(); | ||
if (packageJson.version) { | ||
return { | ||
source: 'package.json', | ||
content: packageJson as { version: string }, | ||
}; | ||
} | ||
|
||
throw new ActionError('No version found in integration.json or package.json'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters