From 8d18935c6d623f62b37e2d2e542e197471c12b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 1 Oct 2024 11:46:27 +0900 Subject: [PATCH] chore: Git tag while bumping crates (#9596) --- tools/swc-releaser/src/main.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/swc-releaser/src/main.rs b/tools/swc-releaser/src/main.rs index 397799f4714..34c9b59bc6f 100644 --- a/tools/swc-releaser/src/main.rs +++ b/tools/swc-releaser/src/main.rs @@ -90,7 +90,8 @@ fn run_bump(workspace_dir: &Path, dry_run: bool) -> Result<()> { update_changelog().with_context(|| "failed to update changelog")?; } - commit(dry_run).context("failed to commit")?; + git_commit(dry_run).context("failed to commit")?; + git_tag_core(dry_run).context("failed to tag core")?; Ok(()) } @@ -126,7 +127,7 @@ fn get_swc_core_version() -> Result { .context("failed to find swc_core") } -fn commit(dry_run: bool) -> Result<()> { +fn git_commit(dry_run: bool) -> Result<()> { let core_ver = get_swc_core_version()?; let mut cmd = Command::new("git"); @@ -146,6 +147,23 @@ fn commit(dry_run: bool) -> Result<()> { Ok(()) } +fn git_tag_core(dry_run: bool) -> Result<()> { + let core_ver = get_swc_core_version()?; + + let mut cmd = Command::new("git"); + cmd.arg("tag").arg(format!("swc_core@v{}", core_ver)); + + eprintln!("Running {:?}", cmd); + + if dry_run { + return Ok(()); + } + + cmd.status().context("failed to run git tag")?; + + Ok(()) +} + struct Bump<'a> { /// Original versions versions: &'a VersionMap,