Skip to content

Publish workflow: Add git tags during publish #6312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions scripts/release/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@ export async function runRelease({
}

/**
* Changeset creates tags for staging releases as well,
* but we should only push tags to Github for prod releases
* Push tags to Github for prod releases only.
*/
if (releaseType === ReleaseType.Production && !dryRun) {
/**
* Push release tags created by changeset in publish() to Github
* Push release tags created by changeset or publishInCI() to Github
*/
await pushReleaseTagsToGithub();
}
Expand Down
13 changes: 11 additions & 2 deletions scripts/release/utils/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function publishInCI(
dryRun: boolean
) {
const taskArray = [];
const tags = [];
for (const pkg of updatedPkgs) {
const path = await mapPkgNameToPkgPath(pkg);

Expand Down Expand Up @@ -79,8 +80,10 @@ export async function publishInCI(
continue;
}

const tag = `${pkg}@${version}`;
tags.push(tag);
taskArray.push({
title: `📦 ${pkg}@${version}`,
title: `📦 ${tag}`,
task: () => publishPackageInCI(pkg, npmTag, dryRun)
});
}
Expand All @@ -91,7 +94,13 @@ export async function publishInCI(
});

console.log('\r\nPublishing Packages to NPM:');
return tasks.run();
await tasks.run();

// Create git tags.
for (const tag of tags) {
await exec(`git tag ${tag}`);
console.log(`Added git tag ${tag}.`);
}
}

async function publishPackageInCI(
Expand Down