* feat: add release.ts * feat: add utils * chore: add scripts to tsconfig.json include * feat: add changelog logic, component, storybook file, scripts, and update to Node v20.9.0 (LTS) * chore: update packages * feat: use conventionalcommits for changelog preset * feat: update padding, width, and change font to mono * feat: refactor to use DialogProvider * chore: remove extra args * feat: update CHANGELOG.md, add title, and add button * refactor: use hook * chore: fix typo
28 lines
980 B
TypeScript
28 lines
980 B
TypeScript
import type { SimpleGit } from 'simple-git';
|
|
import { simpleGit } from 'simple-git';
|
|
|
|
/**
|
|
* Determines the source reference based on the destination branch.
|
|
* @param destinationBranch - The destination branch for the release.
|
|
* @returns A Promise that resolves to the source reference.
|
|
* @throws Error if an invalid destination branch is provided.
|
|
*/
|
|
export async function getSourceRef(destinationBranch: string): Promise<string> {
|
|
const git: SimpleGit = simpleGit();
|
|
|
|
switch (destinationBranch) {
|
|
case 'preview':
|
|
return 'develop';
|
|
case 'production':
|
|
// Get the latest tag from the repository
|
|
const tags = await git.tags();
|
|
const latestTag = tags.latest;
|
|
if (!latestTag) {
|
|
throw new Error('No tags found in the repository');
|
|
}
|
|
return latestTag;
|
|
default:
|
|
throw new Error(`Invalid destination branch: ${destinationBranch}`);
|
|
}
|
|
}
|