diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f88bf58..457658c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -4,6 +4,7 @@ permissions: on: push: + branches: [main] tags: - '[v]?[0-9]+.[0-9]+.[0-9]+' @@ -137,18 +138,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - publish-cargo: - name: Publishing to Cargo - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo publish - env: - - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - diff --git a/Cargo.lock b/Cargo.lock index 886edfc..7ab4794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3011,7 +3011,7 @@ dependencies = [ [[package]] name = "television-channels" -version = "0.0.0" +version = "0.0.3" dependencies = [ "clap", "color-eyre", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "television-derive" -version = "0.0.0" +version = "0.0.3" dependencies = [ "proc-macro2", "quote", @@ -3039,7 +3039,7 @@ dependencies = [ [[package]] name = "television-fuzzy" -version = "0.0.0" +version = "0.0.3" dependencies = [ "nucleo", "parking_lot", @@ -3047,7 +3047,7 @@ dependencies = [ [[package]] name = "television-previewers" -version = "0.0.0" +version = "0.0.3" dependencies = [ "color-eyre", "devicons", @@ -3063,7 +3063,7 @@ dependencies = [ [[package]] name = "television-utils" -version = "0.0.0" +version = "0.0.3" dependencies = [ "bat", "color-eyre", diff --git a/Cargo.toml b/Cargo.toml index f61e91e..538e8bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,20 +15,45 @@ categories = [ "concurrency", "development-tools", ] +include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs", ".config/config.toml"] +rust-version = "1.80.0" + +[workspace] +resolver = "2" +members = ["crates/television-*"] + +[workspace.package] +edition = "2021" +description = "The revolution will be televised." +license = "MIT" +authors = ["Alexandre Pasmantier "] +repository = "https://github.com/alexpasmantier/television" +homepage = "https://github.com/alexpasmantier/television" +keywords = ["search", "fuzzy", "preview", "tui", "terminal"] +categories = [ + "command-line-utilities", + "command-line-interface", + "concurrency", + "development-tools", +] include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs"] rust-version = "1.80.0" + [[bin]] bench = false path = "crates/television/main.rs" name = "tv" [dependencies] -television-fuzzy = { workspace = true} -television-derive = { workspace = true} -television-channels = { workspace = true} -television-previewers = { workspace = true} -television-utils = { workspace = true} +# workspace dependencies +television-fuzzy = { path = "crates/television-fuzzy", version = "0.0.3" } +television-derive = { path = "crates/television-derive", version = "0.0.3" } +television-channels = { path = "crates/television-channels", version = "0.0.3" } +television-previewers = { path = "crates/television-previewers", version = "0.0.3" } +television-utils = { path = "crates/television-utils", version = "0.0.3" } + +# external dependencies better-panic = "0.3.0" clap = { version = "4.4.5", features = [ "derive", @@ -71,6 +96,8 @@ human-panic = "2.0.2" pretty_assertions = "1.4.1" termtree = "0.5.1" copypasta = "0.10.1" + + [build-dependencies] anyhow = "1.0.86" vergen-gix = { version = "1.0.0", features = ["build", "cargo", "rustc"] } @@ -78,34 +105,6 @@ vergen-gix = { version = "1.0.0", features = ["build", "cargo", "rustc"] } [target.'cfg(target_os = "macos")'.dependencies] crossterm = { version = "0.28.1", features = ["serde", "use-dev-tty"] } -[workspace] -resolver = "2" -members = ["crates/television-channels", "crates/television-derive", "crates/television-fuzzy", "crates/television-previewers", "crates/television-utils"] - -[workspace.dependencies] -television-derive = { path = "crates/television-derive", version = "0.0.0" } -television-fuzzy = { path = "crates/television-fuzzy", version = "0.0.0" } -television-previewers = { path = "crates/television-previewers", version = "0.0.0" } -television-utils = { path = "crates/television-utils", version = "0.0.0" } -television-channels = { path = "crates/television-channels", version = "0.0.0" } - -[workspace.package] -edition = "2021" -description = "The revolution will be televised." -license = "MIT" -authors = ["Alexandre Pasmantier "] -build = "build.rs" -repository = "https://github.com/alexpasmantier/television" -homepage = "https://github.com/alexpasmantier/television" -keywords = ["search", "fuzzy", "preview", "tui", "terminal"] -categories = [ - "command-line-utilities", - "command-line-interface", - "concurrency", - "development-tools", -] -include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs"] -rust-version = "1.80.0" diff --git a/Makefile b/Makefile index 304861c..bb58829 100644 --- a/Makefile +++ b/Makefile @@ -46,3 +46,11 @@ run: test: @echo "Testing $(NAME)" @cargo test --all + +bump-workspace: + @echo "Bumping workspace" + @./scripts/bump.sh + +publish: + @echo "Publishing $(NAME)" + @./scripts/publish.sh diff --git a/crates/television-channels/Cargo.toml b/crates/television-channels/Cargo.toml index 506d4ef..8d019bf 100644 --- a/crates/television-channels/Cargo.toml +++ b/crates/television-channels/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "television-channels" -version = "0.0.0" +version = "0.0.3" +description.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true @@ -8,15 +9,13 @@ keywords.workspace = true categories.workspace = true readme.workspace = true license.workspace = true -include.workspace = true edition.workspace = true rust-version.workspace = true -publish = false [dependencies] -television-fuzzy = {workspace = true} -television-utils = {workspace = true} -television-derive = {workspace = true} +television-fuzzy = { path = "../television-fuzzy", version = "0.0.3" } +television-utils = { path = "../television-utils", version = "0.0.3" } +television-derive = { path = "../television-derive", version = "0.0.3" } devicons = "0.6.11" tracing = "0.1.40" eyre = "0.6.12" diff --git a/crates/television-derive/Cargo.toml b/crates/television-derive/Cargo.toml index 5495017..affd945 100644 --- a/crates/television-derive/Cargo.toml +++ b/crates/television-derive/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "television-derive" -version = "0.0.0" +version = "0.0.3" +description.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true @@ -8,10 +9,8 @@ keywords.workspace = true categories.workspace = true readme.workspace = true license.workspace = true -include.workspace = true edition.workspace = true rust-version.workspace = true -publish = false [dependencies] proc-macro2 = "1.0.87" diff --git a/crates/television-fuzzy/Cargo.toml b/crates/television-fuzzy/Cargo.toml index 5b489aa..4eace45 100644 --- a/crates/television-fuzzy/Cargo.toml +++ b/crates/television-fuzzy/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "television-fuzzy" -version = "0.0.0" +version = "0.0.3" +description.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true @@ -8,10 +9,8 @@ keywords.workspace = true categories.workspace = true readme.workspace = true license.workspace = true -include.workspace = true edition.workspace = true rust-version.workspace = true -publish = false [dependencies] nucleo = "0.5.0" diff --git a/crates/television-previewers/Cargo.toml b/crates/television-previewers/Cargo.toml index 744fb44..480d6aa 100644 --- a/crates/television-previewers/Cargo.toml +++ b/crates/television-previewers/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "television-previewers" -version = "0.0.0" +version = "0.0.3" +description.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true @@ -8,15 +9,13 @@ keywords.workspace = true categories.workspace = true readme.workspace = true license.workspace = true -include.workspace = true edition.workspace = true rust-version.workspace = true -publish = false [dependencies] syntect = "5.2.0" -television-channels = { workspace = true } -television-utils = { workspace = true } +television-channels = { path = "../television-channels", version = "0.0.3" } +television-utils = { path = "../television-utils", version = "0.0.3" } tracing = "0.1.40" parking_lot = "0.12.3" tokio = "1.41.1" diff --git a/crates/television-utils/Cargo.toml b/crates/television-utils/Cargo.toml index c73a503..d587014 100644 --- a/crates/television-utils/Cargo.toml +++ b/crates/television-utils/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "television-utils" -version = "0.0.0" +version = "0.0.3" +description.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true @@ -8,10 +9,8 @@ keywords.workspace = true categories.workspace = true readme.workspace = true license.workspace = true -include.workspace = true edition.workspace = true rust-version.workspace = true -publish = false [dependencies] ignore = "0.4.23" diff --git a/scripts/bump.sh b/scripts/bump.sh new file mode 100755 index 0000000..a4131c7 --- /dev/null +++ b/scripts/bump.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -euo pipefail + +# get new version +NEW_VERSION=$(python scripts/get_version.py) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $SCRIPT_DIR/.. + +echo "Bumping version in workspace crates: $NEW_VERSION" + +TOML_FILES="$(git ls-files 'crates/television-*/Cargo.toml')" +perl -pi -e "s/^version .*= .*\$/version = \"$NEW_VERSION\"/" -- $TOML_FILES +perl -pi -e "s/^(television-[a-z]+)\\s*=\\s*{.*\$/\\1 = { path = \"..\/\\1\", version = \"$NEW_VERSION\" }/" -- $TOML_FILES + +echo "Bumping root Cargo.toml dependencies to $NEW_VERSION" + +perl -pi -e "s/^(television-[a-z]+)\\s*=\\s*{.*\$/\\1 = { path = \"crates\/\\1\", version = \"$NEW_VERSION\" }/" -- Cargo.toml + +echo "Done" diff --git a/scripts/get_version.py b/scripts/get_version.py new file mode 100644 index 0000000..8619c0b --- /dev/null +++ b/scripts/get_version.py @@ -0,0 +1,28 @@ +import re + + +WORKSPACE_CARGO_PATH = "Cargo.toml" +VERSION_RE = re.compile(r'version\s+=\s+"(\d+\.\d+\.\d+)"') + + +def get_version() -> str: + with open(WORKSPACE_CARGO_PATH, "r") as f: + lines = f.readlines() + l = 0 + for i, line in enumerate(lines): + if line == "[dependencies]": + l = i + break + for i in range(l, len(lines)): + if lines[i].startswith("television-"): + return VERSION_RE.search(lines[i]).group(1) + return "0.0.0" + + +def bump_version(version: str) -> str: + major, minor, patch = version.split(".") + return f"{major}.{minor}.{int(patch) + 1}" + +if __name__ == "__main__": + print(bump_version(get_version())) + diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..a945f48 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,11 @@ +cargo publish -p television-derive +sleep 20 +cargo publish -p television-fuzzy +sleep 20 +cargo publish -p television-utils +sleep 20 +cargo publish -p television-channels +sleep 20 +cargo publish -p television-previewers +sleep 20 +cargo publish -p television