mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-03 01:50:12 +00:00
fix(cargo workspace): fix cargo workspace structure and dependencies (#15)
* fix(cargo workspace): fix cargo workspace dependencies * add bump and publish scripts * more version automation scripts
This commit is contained in:
parent
d2e7789612
commit
b1fe0182f8
16
.github/workflows/cd.yml
vendored
16
.github/workflows/cd.yml
vendored
@ -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 }}
|
||||
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -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",
|
||||
|
65
Cargo.toml
65
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 <alex.pasmant@gmail.com>"]
|
||||
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 <alex.pasmant@gmail.com>"]
|
||||
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"
|
||||
|
||||
|
||||
|
||||
|
8
Makefile
8
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
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
20
scripts/bump.sh
Executable file
20
scripts/bump.sh
Executable file
@ -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"
|
28
scripts/get_version.py
Normal file
28
scripts/get_version.py
Normal file
@ -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()))
|
||||
|
11
scripts/publish.sh
Executable file
11
scripts/publish.sh
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user