Skip to content

Commit

Permalink
chore: fixing release
Browse files Browse the repository at this point in the history
  • Loading branch information
corymhall committed Dec 10, 2023
1 parent 4f31cc3 commit 95bba57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ project.github?.tryFindWorkflow('release')?.file?.patch(JsonPatch.replace(
'mv dist/package.json ./',
'mv dist/projenrc ./',
'mv dist/.git ./',
'git config user.name "github-actions"',
'git config user.email "[email protected]"',
'yarn install',
'npx ts-node projenrc/release-version.ts',
].join(' && '),
));

project.gitignore.exclude('dist/package.json');
project.gitignore.exclude('dist/projenrc');

Expand Down
25 changes: 20 additions & 5 deletions projenrc/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,40 @@ export async function release(cwd: string, options: BumpOptions) {
logging.info(
`${releaseTagFile} has resolved version: ${tagVersion}`,
);
logging.info(JSON.stringify(options));

const [majorVersion, minorVersion] = tagVersion.split('.');

const cmds = [
`gh release create ${tagVersion} -R ${options.githubRepo} -F dist/changelog.md -t ${tagVersion} --target ${options.githubRef}`,
`git tag ${majorVersion} --force`,
`git tag ${majorVersion}.${minorVersion} --force`,
'git push origin --tags',
// `gh release create ${tagVersion} -R ${options.githubRepo} -F dist/changelog.md -t ${tagVersion} --target ${options.githubRef}`,
createTagCmd(options.githubRepo, majorVersion, options.githubRef),
createTagCmd(options.githubRepo, `${majorVersion}.${minorVersion}`, options.githubRef),
];
if (options.dryRun) {
cmds.forEach(cmd => {
logging.info(cmd);
});
} else {
cmds.forEach(cmd => {
logging.info(cmd);
exec(cmd, { cwd });
});
}
}

function createTagCmd(repo: string, tagValue: string, ref: string): string {
return [
'gh api',
'--method POST',
'-H "Accept: application/vnd.github+json"',
'-H "X-GitHub-Api-Version: 2022-11-28"',
`/repos/${repo}/git/refs`,
`-f ref='refs/tags/${tagValue}'`,
`-f sha='${ref}'`,
'-F force=true',
].join(' ');
}

const releaseTagFile = process.env.RELEASETAG;
const githubRepo = process.env.GITHUB_REPOSITORY;
const githubRef = process.env.GITHUB_REF;
Expand All @@ -73,7 +88,7 @@ if (!githubRef) {
}

const opts: BumpOptions = {
dryRun: dryRun == 'true',
dryRun: dryRun === 'true',
releaseTagFile,
githubRef,
githubRepo,
Expand Down

0 comments on commit 95bba57

Please sign in to comment.