Skip to content

Commit

Permalink
chore(ci): Integrate changeset (#9284)
Browse files Browse the repository at this point in the history
**Description:**

@swc-bot works, but as it works by creating a commit after merging each PR, it makes reading commit log harder and it causes problems with caching in CI.

Changeset itself does not support managing Rust crates, but there's a crate for this purpose.
  • Loading branch information
kdy1 committed Jul 19, 2024
1 parent eb83471 commit 6afa40b
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 26 deletions.
9 changes: 7 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }

[alias]
codegen = "run --package generate-code --"
xtask = "run --package xtask --"
bump = "run --package swc-releaser -- bump"
codegen = "run --package generate-code --"
releaser = "run --package swc-releaser --"
xtask = "run --package xtask --"

[build]

Expand Down
5 changes: 5 additions & 0 deletions .changeset/calm-snakes-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
dbg-swc: patch
---

chore(ci): Integrate `knope` and changeset
24 changes: 0 additions & 24 deletions .github/workflows/bot.yml

This file was deleted.

15 changes: 15 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"crates/swc_typescript",
"crates/swc_fast_ts_strip",
"tools/generate-code",
"tools/swc-releaser",
]
resolver = "2"

Expand Down Expand Up @@ -59,6 +60,7 @@ resolver = "2"
bumpalo = "3.16.0"
cargo_metadata = "0.18.1"
cfg-if = "1.0.0"
changesets = "0.2.2"
chrono = "0.4.38"
codspeed-criterion-compat = "2.6.0"
console_error_panic_hook = "0.1.7"
Expand Down
2 changes: 2 additions & 0 deletions knope.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[package]
changelog = "CHANGELOG.md"
12 changes: 12 additions & 0 deletions tools/swc-releaser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
edition = "2021"
license.workspace = true
name = "swc-releaser"
publish = false
repository = { workspace = true }
version = "0.1.0"

[dependencies]
anyhow = { workspace = true }
changesets = { workspace = true }
clap = { version = "4.5.9", features = ["derive"] }
101 changes: 101 additions & 0 deletions tools/swc-releaser/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
use std::{
env,
path::{Path, PathBuf},
process::Command,
};

use anyhow::{Context, Result};
use changesets::ChangeType;
use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
struct CliArs {
#[clap(long)]
pub dry_run: bool,

#[clap(subcommand)]
pub cmd: Cmd,
}

#[derive(Debug, Subcommand)]
enum Cmd {
Bump,
}

fn main() -> Result<()> {
let CliArs { dry_run, cmd } = CliArs::parse();

let workspace_dir = env::var("CARGO_WORKSPACE_DIR")
.map(PathBuf::from)