generated from PlexSheep/rs-base
Compare commits
No commits in common. "a2c699bb9803cc69f55455f0b94ba21a12448e6f" and "2baacdf7391f5b28c6a69fd1c5ffce3d16f47c7a" have entirely different histories.
a2c699bb98
...
2baacdf739
8 changed files with 10 additions and 219 deletions
|
@ -1,25 +0,0 @@
|
||||||
changelog:
|
|
||||||
enable: true
|
|
||||||
git-log: true
|
|
||||||
|
|
||||||
uses:
|
|
||||||
cargo:
|
|
||||||
publish: true
|
|
||||||
# tokens are loaded from ~/.cargo/config.toml
|
|
||||||
registries:
|
|
||||||
- crates.io
|
|
||||||
- example.com
|
|
||||||
|
|
||||||
api:
|
|
||||||
github:
|
|
||||||
type: github
|
|
||||||
endpoint: https://github.com
|
|
||||||
auth:
|
|
||||||
user: myUserName
|
|
||||||
pass: token_superimportantsecret
|
|
||||||
myserv:
|
|
||||||
type: gitea
|
|
||||||
endpoint: https://git.example.com
|
|
||||||
auth:
|
|
||||||
user: myUserName
|
|
||||||
pass: importantsecrettoken
|
|
14
Cargo.toml
14
Cargo.toml
|
@ -20,20 +20,6 @@ keywords = [
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.79"
|
|
||||||
clap = { version = "4.4.18", features = ["derive"] }
|
|
||||||
clap-num = "1.1.1"
|
|
||||||
clap-verbosity-flag = "2.1.2"
|
|
||||||
git2 = "0.18.1"
|
|
||||||
libpt = { version = "0.3.11", features = ["log"] }
|
libpt = { version = "0.3.11", features = ["log"] }
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
serde_yaml = "0.9.30"
|
serde_yaml = "0.9.30"
|
||||||
thiserror = "1.0.56"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "autocrate"
|
|
||||||
path = "src/main.rs"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "autocrate"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
19
README.md
19
README.md
|
@ -85,30 +85,21 @@ repository. It should contain the following parameters (replace the placeholders
|
||||||
An example `.autocrate.yaml` could look like this:
|
An example `.autocrate.yaml` could look like this:
|
||||||
```yaml
|
```yaml
|
||||||
changelog:
|
changelog:
|
||||||
enable: true
|
- enable: true
|
||||||
git-log: true
|
- git-log: true
|
||||||
|
|
||||||
uses:
|
uses:
|
||||||
cargo:
|
- cargo:
|
||||||
publish: true
|
- publish = true
|
||||||
# tokens are loaded from ~/.cargo/config.toml
|
# tokens are loaded from ~/.cargo/config.toml
|
||||||
registries:
|
- registries:
|
||||||
- crates.io
|
- crates.io
|
||||||
- example.com
|
- example.com
|
||||||
|
|
||||||
api:
|
api:
|
||||||
github:
|
github:
|
||||||
type: github
|
|
||||||
endpoint: https://github.com
|
|
||||||
auth:
|
|
||||||
user: myUserName
|
user: myUserName
|
||||||
pass: token_superimportantsecret
|
pass: token_superimportantsecret
|
||||||
myserv:
|
|
||||||
type: gitea
|
|
||||||
endpoint: https://git.example.com
|
|
||||||
auth:
|
|
||||||
user: myUserName
|
|
||||||
pass: importantsecrettoken
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using Autocrate
|
## Using Autocrate
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
TOKEN=$(cat ~/.git-credentials | grep 'git.cscherr.de' | grep -P '(?:)[^:]*(?=@)' -o)
|
TOKEN=$(cat ~/.git-credentials | grep 'git.cscherr.de' | grep -P '(?:)[^:]*(?=@)' -o)
|
||||||
NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
|
NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
|
||||||
GIT_COMMIT_SHA=$(git rev-parse HEAD)
|
GIT_COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
REPO=${PWD##*/} # name of cwd
|
REPO=autocrate
|
||||||
BODY="
|
BODY="
|
||||||
$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --decorate)
|
$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --decorate)
|
||||||
"
|
"
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
use serde;
|
|
||||||
use serde_yaml;
|
|
||||||
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use libpt::log::{Level, Logger};
|
|
||||||
|
|
||||||
use clap::Parser;
|
|
||||||
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
|
||||||
|
|
||||||
/// short about section displayed in help
|
|
||||||
const ABOUT_ROOT: &'static str = r##"
|
|
||||||
Release Manager for Your Projects on Gitea, GitHub, and GitLab.
|
|
||||||
"##;
|
|
||||||
/// longer about section displayed in help, is combined with [the short help](ABOUT_ROOT)
|
|
||||||
static LONG_ABOUT_ROOT: &'static str = r##""##;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Parser)]
|
|
||||||
#[command(
|
|
||||||
author,
|
|
||||||
version,
|
|
||||||
about = ABOUT_ROOT,
|
|
||||||
long_about = format!("{}{}", ABOUT_ROOT ,LONG_ABOUT_ROOT),
|
|
||||||
help_template =
|
|
||||||
r#"{about-section}
|
|
||||||
{usage-heading} {usage}
|
|
||||||
{all-args}{tab}
|
|
||||||
|
|
||||||
autocrate: {version}
|
|
||||||
Author: {author-with-newline}
|
|
||||||
"#
|
|
||||||
)]
|
|
||||||
pub struct Cli {
|
|
||||||
// clap_verbosity_flag seems to make this a global option implicitly
|
|
||||||
/// set a verbosity, multiple allowed (f.e. -vvv)
|
|
||||||
#[command(flatten)]
|
|
||||||
pub(crate) verbose: Verbosity<InfoLevel>,
|
|
||||||
|
|
||||||
/// show additional logging meta data
|
|
||||||
#[arg(long)]
|
|
||||||
pub(crate) meta: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cli {
|
|
||||||
pub fn cli_parse() -> Self {
|
|
||||||
let cli = Self::parse();
|
|
||||||
let ll: Level = match cli.verbose.log_level().unwrap().as_str() {
|
|
||||||
"TRACE" => Level::TRACE,
|
|
||||||
"DEBUG" => Level::DEBUG,
|
|
||||||
"INFO" => Level::INFO,
|
|
||||||
"WARN" => Level::WARN,
|
|
||||||
"ERROR" => Level::ERROR,
|
|
||||||
_ => {
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if cli.meta {
|
|
||||||
Logger::init(None, Some(ll), true).expect("could not initialize Logger");
|
|
||||||
} else {
|
|
||||||
// less verbose version
|
|
||||||
Logger::init_mini(Some(ll)).expect("could not initialize Logger");
|
|
||||||
}
|
|
||||||
return cli;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
use std::{
|
|
||||||
fmt::{write, Debug}, fs::File, path::PathBuf
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
|
||||||
use git2;
|
|
||||||
use libpt::log::error;
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use self::cli::Cli;
|
|
||||||
|
|
||||||
pub mod cli;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub struct Changelog {
|
|
||||||
enabled: bool,
|
|
||||||
git_log: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub struct Uses {
|
|
||||||
cargo: Option<Cargo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub struct Cargo {
|
|
||||||
publish: bool,
|
|
||||||
registries: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub struct Api {
|
|
||||||
api_type: ApiType,
|
|
||||||
publish: bool,
|
|
||||||
registries: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub enum ApiType {
|
|
||||||
Gitea,
|
|
||||||
Gitlab,
|
|
||||||
Github,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
|
||||||
pub struct YamlConfig {
|
|
||||||
pub changelog: Changelog,
|
|
||||||
pub uses: Uses,
|
|
||||||
pub apis: Vec<Api>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Config {
|
|
||||||
pub yaml: YamlConfig,
|
|
||||||
pub repo: git2::Repository,
|
|
||||||
pub path: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Config {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"{}",
|
|
||||||
format!(
|
|
||||||
"Config {{yaml: {:?}, repo_path: {:?}}}",
|
|
||||||
self.yaml, self.path
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Config {
|
|
||||||
pub fn load(cli: Cli) -> Result<Self> {
|
|
||||||
let repo = match git2::Repository::open_from_env() {
|
|
||||||
Ok(repo) => repo,
|
|
||||||
Err(err) => {
|
|
||||||
let msg = format!("could not find a git repository: {err:?}");
|
|
||||||
error!("{}", msg);
|
|
||||||
return Err(anyhow!(msg));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let mut path = repo.path().to_path_buf();
|
|
||||||
path.pop(); // we want the real root, not the `.git` dir
|
|
||||||
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
pub mod config;
|
|
13
src/main.rs
13
src/main.rs
|
@ -1,12 +1,3 @@
|
||||||
use anyhow::Result;
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
mod config;
|
|
||||||
use config::{cli::Cli, Config};
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
|
||||||
let cli = Cli::cli_parse();
|
|
||||||
let config = Config::load(cli.clone())?;
|
|
||||||
|
|
||||||
dbg!(config);
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue