From 6d86670c36587ee51445c0108103caa5d3e4a04f Mon Sep 17 00:00:00 2001 From: yjl9903 Date: Fri, 6 Oct 2023 14:43:04 +0800 Subject: [PATCH] feat: add release script --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- release.ts | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 release.ts diff --git a/Cargo.lock b/Cargo.lock index 5f1c44b..7f645aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,7 +51,7 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "catj" -version = "0.2.0" +version = "0.2.1" dependencies = [ "cgroups-rs", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 92525b7..935dd06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "catj" -version = "0.2.0" +version = "0.2.1" authors = ["XLor yjl9903@outlook.com"] edition = "2021" diff --git a/README.md b/README.md index d8e1ccd..9f653b9 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ $ curl -fsSL https://bina.egoist.sh/CaCatHead/CatBox | sh # Check installation $ catj --version -catj 0.1.5 +catj 0.2.1 # Init cgroup for current user $ ./init.sh $USER diff --git a/release.ts b/release.ts new file mode 100755 index 0000000..47e4edb --- /dev/null +++ b/release.ts @@ -0,0 +1,18 @@ +#!/usr/bin/env optc + +/// + +export default async function(version: string) { + if (!/^\d+\.\d+\.\d+$/.test(version)) { + return; + } + + const toml = readTextFile('Cargo.toml'); + writeTextFile('Cargo.toml', toml.replace(/version = "\d+\.\d+\.\d+"/, `version = "${version}"`)); + writeTextFile('README.md', readTextFile('README.md').replace(/catj \d+\.\d+\.\d+/, `catj ${version}`)); + + await $`git add Cargo.toml README.md`; + await $`git commit -m "chore: release v${version}"`; + await $`git tag -a v${version} -m "chore: release v${version}"`; + await $`git push --tags origin main`; +}