Compare commits

..

No commits in common. "main" and "0.1.0" have entirely different histories.
main ... 0.1.0

46 changed files with 618 additions and 2320 deletions

View File

@ -1,2 +0,0 @@
kind: template
load: cuddle-rust-cli-plan.yaml

View File

@ -6,144 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.5.0] - 2024-04-09
### Added
- stuff
- with rust version
- add rust actions
## [0.4.0] - 2024-04-08
### Added
- remove comment
- add jq
- fix tests
- update deps
- update chrono
- remove deps
- without dagger
### Fixed
- *(deps)* update rust crate futures to 0.3.30
- *(deps)* update rust crate futures to 0.3.29
### Other
- *(deps)* update all dependencies
- something
- *(deps)* update rust crate chrono to 0.4.28
- *(deps)* update rust crate chrono to 0.4.27
- *(deps)* update rust crate clap to 4.4.1
- *(deps)* update rust crate url to 2.4.1
- *(deps)* update rust crate regex to 1.9.4
- *(deps)* update rust crate clap to 4.4.0
- *(deps)* update rust crate reqwest to 0.11.20
- *(deps)* update rust crate clap to 4.3.24
- *(deps)* update rust crate reqwest to 0.11.19
- *(deps)* update rust crate clap to 4.3.23
- *(deps)* update all dependencies
## [0.3.0] - 2023-08-13
### Added
- *(ci)* with dagger-rust components
- allow v in start of versions
- *(json-edit)* added json-edit to update some json content with next global version
### Fixed
- *(git)* make sure we always fail on exit code != 0
- *(json-edit)* with actual arg instead of stupid str replace
- *(ci)* without token
- *(docs)* check fix version
- *(crate)* initial pr always included the entire changelog
- *(crate)* always prefix with 'v' when creating prs, or releases (#9)
### Other
- remove unnused arguments
- *(ci)* fix release step
- add dagger-rust and dagger-cuddle-please
- *(deps)* update rust crate clap to 4.3.21
- *(deps)* update rust crate clap to 4.3.20
- *(deps)* update rust crate parse-changelog to 0.6.2
- *(deps)* update rust crate regex to 1.9.3
- *(deps)* update rust crate regex to 1.9.2
- remove cr
- *(json-edit)* clarify errors
- *(docs)* remove 0.2 checklist
## [0.2.1] - 2023-08-04
### Docs
- *(check)* 0.2 milestone, forgot for 0.2.0
## [0.2.0] - 2023-08-03
### Added
- *(ci)* with pr
- *(ci)* on pr only
- *(ci)* with ci:pr.sh file
- *(ci)* update ci with best settings
- *(ci)* pr ignore master
- *(ci)* ignore pr for master
- add git init
- with actual docker login
- with docker login
- back to default
- with ldd
- only ci
- with musl instead
- with some debug stuff
- with shared volume
- with shared volume
- without going into module
- set to use prefix when in ci
- only master
- with working main
- ci:main script for ci
- with run script
- fixed stuff
- with ultra caching
- with ci
- with set -e for abort
- with drone yml
- add mkdocs build
- add basic version
- update with repository
- add publishable to rest
- hack get in control of log level
### Docs
- fix admonitions
- add docs
- remove 0.1 milestone
### Fixed
- with actual install
### Other
- *(rust)* fmt
- *(rust)* clippy fix
- *(ci)* no please for pr
- *(ci)* rename pr -> pull-request in ci:pr
- remove faulty test
- add git (alpine)
- add git
- musl
- remember package name
- rename variable
- openssl-src
- with openssl-dev
- with pkg config sysroot
- with musl dev
- with build-essential
- with libssl-dev
- with token
- add mit license
- add logging to stdout
- update versions
- add docs
## [0.1.0] - 2023-08-01
### Added

1494
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +1,30 @@
[workspace]
members = [
"crates/*"
]
members = ["crates/cuddle-please", "crates/cuddle-please-frontend", "crates/cuddle-please-commands", "crates/cuddle-please-misc"]
resolver = "2"
[workspace.dependencies]
cuddle-please = { path = "crates/cuddle-please", version = "0.1.0" }
cuddle-please-frontend = { path = "crates/cuddle-please-frontend", version = "0.1.0" }
cuddle-please-commands = { path = "crates/cuddle-please-commands", version = "0.1.0" }
cuddle-please-misc = { path = "crates/cuddle-please-misc", version = "0.1.0" }
cuddle-please-release-strategy = { path = "crates/cuddle-please-release-strategy", version = "0.1.0" }
cuddle-please-actions = { path = "crates/cuddle-please-actions", version = "0.1.0" }
cuddle-please = { path = "crates/cuddle-please" }
cuddle-please-frontend = { path = "crates/cuddle-please-frontend" }
cuddle-please-commands = { path = "crates/cuddle-please-commands" }
cuddle-please-misc = { path = "crates/cuddle-please-misc" }
anyhow = { version = "1.0.81" }
anyhow = { version = "1.0.72" }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
clap = { version = "4.5.4", features = ["derive", "env"] }
tracing-subscriber = { version = "0.3.17" }
clap = { version = "4.3.19", features = ["derive", "env"] }
dotenv = { version = "0.15.0" }
url = { version = "2.5.0" }
serde_yaml = { version = "0.9.34+deprecated" }
yaml-rust2 = {version = "0.8.0"}
url = { version = "2.4.0" }
serde_yaml = { version = "0.9.25" }
serde = { version = "1", features = ["derive"] }
semver = "1.0.22"
semver = "1.0.18"
conventional_commit_parser = "0.9.4"
tempdir = "0.3.7"
reqwest = { version = "0.12.3" }
git-cliff-core = "2.2.0"
regex = "1.10.4"
chrono = "0.4.37"
lazy_static = "1.4.0"
parse-changelog = "0.6.6"
toml_edit = "0.22.9"
reqwest = { version = "0.11.18" }
git-cliff-core = "1.2.0"
regex = "*"
chrono = "*"
lazy_static = "*"
parse-changelog = "*"
tracing-test = "0.2"
pretty_assertions = "1.4"
[workspace.package]
version = "0.5.0"

View File

@ -1,7 +0,0 @@
Copyright 2023 Kasper J. Hermansen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -36,16 +36,32 @@ See docs for more information about installation and some such
## Checklist
### 0.1 Milestone
- [x] Hide unneccessary commands
- [x] Redo configuration frontend
- [x] Refactor command.rs into smaller bits so that bits are easier to test
- [x] Add cuddle.release.yaml to this repo
- [x] Setup temporary git name and email to use for git committing
### 0.2 Milestone
- [ ] Add docs
- [ ] Add asciinema
- [ ] Add examples
- [ ] Fx drone config
- [ ] Releaser
- [ ] On main/master
- [ ] Add reporter for PR and Repositories
- [ ] tbd...
### 0.3 Milestone
- [x] Fix: 0.0.0 -> **v**0.0.0
- [ ] Add release strategies
- [ ] Add reporter for PR and Repositories
- [ ] Add inquire for missing values when needed (when not running in ci or have a proper tty)
- [ ] Break down cuddle-please-misc
- [ ] ci(release): Add cuddle-please release artifacts for the different os and so on.
### 0.x Milestone
- [ ] Add github support
- [ ] Add custom strategies
- [ ] Create docker image
- [ ] Add more granular tests

View File

@ -1,19 +0,0 @@
[package]
name = "cuddle-please-actions"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
readme = "../../README.md"
license-file = "../../LICENSE"
version = "0.1.0"
edition = "2021"
publishable = true
[dependencies]
anyhow.workspace = true
tracing.workspace = true
semver.workspace = true
toml_edit.workspace = true
yaml-rust2.workspace = true
[dev-dependencies]
pretty_assertions.workspace = true

View File

@ -1,9 +0,0 @@
use semver::Version;
use crate::ActionConfig;
pub trait Action {
fn enabled(&self, config: &ActionConfig) -> anyhow::Result<bool>;
fn name(&self) -> String;
fn execute(&self, version: &Version) -> anyhow::Result<()>;
}

View File

@ -1,49 +0,0 @@
use std::ops::Deref;
use anyhow::Context;
pub enum ActionConfig {
Actual { doc: yaml_rust2::Yaml },
None,
}
impl Deref for ActionConfig {
type Target = yaml_rust2::Yaml;
fn deref(&self) -> &Self::Target {
match &self {
ActionConfig::Actual { doc } => doc,
ActionConfig::None => &yaml_rust2::Yaml::BadValue,
}
}
}
impl TryFrom<&str> for ActionConfig {
type Error = anyhow::Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
let mut cuddle = yaml_rust2::YamlLoader::load_from_str(value)?;
if cuddle.len() != 1 {
anyhow::bail!("cuddle.yaml can only be 1 document wide");
}
let doc = cuddle.pop().unwrap();
let doc = doc["please"]["actions"].clone();
if doc.is_badvalue() {
return Ok(Self::None);
}
Ok(Self::Actual { doc })
}
}
impl ActionConfig {
pub fn parse() -> anyhow::Result<Self> {
let cuddle_yaml =
std::fs::read_to_string("cuddle.yaml").context("failed to read cuddle.yaml")?;
Self::try_from(cuddle_yaml.as_str())
}
}

View File

@ -1,45 +0,0 @@
pub(crate) mod actions;
mod config;
mod rust_action;
use std::{ops::Deref, sync::Arc};
use catalog::RustAction;
pub use config::ActionConfig;
use semver::Version;
pub mod catalog {
pub use crate::rust_action::*;
}
pub struct Action(Arc<dyn actions::Action>);
impl Deref for Action {
type Target = Arc<dyn actions::Action>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub struct Actions(Vec<Action>);
impl Actions {
pub fn from_cuddle() -> anyhow::Result<Self> {
let config = ActionConfig::parse()?;
Ok(Self(
vec![Action(Arc::new(RustAction::new()))]
.into_iter()
.filter(|a| a.enabled(&config).unwrap_or_default())
.collect(),
))
}
pub fn execute(&self, version: &Version) -> anyhow::Result<()> {
for action in &self.0 {
action.execute(version)?;
}
Ok(())
}
}

View File

@ -1,237 +0,0 @@
use std::io::Write;
use anyhow::Context;
use crate::{actions::Action, ActionConfig};
#[derive(Default, Clone)]
pub struct RustAction {}
impl RustAction {
pub fn new() -> Self {
Self {}
}
fn execute_content(
&self,
version: &semver::Version,
cargo_content: &str,
) -> anyhow::Result<String> {
tracing::trace!("parsing Cargo.toml file as tolm");
let mut cargo_doc = cargo_content.parse::<toml_edit::DocumentMut>()?;
tracing::debug!(
"updating cargo workspace package version to {}",
version.to_string()
);
let workspace = if cargo_doc.contains_table("workspace") {
cargo_doc["workspace"].as_table_mut().unwrap()
} else {
let mut t = toml_edit::Table::new();
t.set_implicit(true);
cargo_doc["workspace"] = toml_edit::Item::Table(t);
cargo_doc["workspace"].as_table_mut().unwrap()
};
let package = workspace["package"].or_insert(toml_edit::table());
package["version"] = toml_edit::value(version.to_string());
Ok(cargo_doc.to_string())
}
}
impl Action for RustAction {
fn enabled(&self, config: &ActionConfig) -> anyhow::Result<bool> {
if let Ok(v) = std::env::var("CUDDLE_PLEASE_RUST_ACTION") {
if let Ok(true) = v.parse::<bool>() {
return Ok(true);
}
}
let val = &config[self.name().as_str()];
if val.is_badvalue() {
return Ok(false);
}
Ok(val.as_bool().unwrap_or(true))
}
fn name(&self) -> String {
"rust".into()
}
fn execute(&self, version: &semver::Version) -> anyhow::Result<()> {
tracing::info!(
"running rust action for version: {} and file: Cargo.toml",
version.to_string()
);
let path = std::path::PathBuf::from("Cargo.toml");
tracing::trace!("reading Cargo.toml");
let file = match std::fs::read_to_string(&path) {
Ok(file) => file,
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => {
anyhow::bail!("err: Cargo.toml was not found in dir")
}
_ => Err(e)?,
},
};
let cargo_doc = self.execute_content(version, &file)?;
let mut cargo_file = std::fs::File::create(&path)?;
cargo_file.write_all(cargo_doc.as_bytes())?;
cargo_file.sync_all()?;
tracing::debug!("finished writing cargo file");
Ok(())
}
}
#[cfg(test)]
mod test {
use semver::{BuildMetadata, Prerelease};
use crate::{actions::Action, ActionConfig};
use super::RustAction;
#[test]
fn test_is_enabled() {
let config = ActionConfig::try_from(
r#"
please:
actions:
rust: true
"#,
)
.unwrap();
let enabled = RustAction::new().enabled(&config).unwrap();
assert!(enabled)
}
#[test]
fn test_is_disabled_by_default() {
let config = ActionConfig::try_from(
r#"
please:
"#,
)
.unwrap();
let enabled = RustAction::new().enabled(&config).unwrap();
assert!(!enabled)
}
#[test]
fn test_is_disabled() {
let config = ActionConfig::try_from(
r#"
please:
actions:
rust: false
"#,
)
.unwrap();
let enabled = RustAction::new().enabled(&config).unwrap();
assert!(!enabled)
}
#[test]
fn test_missing_value_is_enabled() {
let config = ActionConfig::try_from(
r#"
please:
actions:
rust:
"#,
)
.unwrap();
let enabled = RustAction::new().enabled(&config).unwrap();
assert!(enabled)
}
#[test]
fn test_can_edit_empty_file() {
let output = RustAction::default()
.execute_content(
&semver::Version {
major: 0,
minor: 1,
patch: 0,
pre: Prerelease::default(),
build: BuildMetadata::default(),
},
"",
)
.unwrap();
pretty_assertions::assert_eq!(
r#"[workspace.package]
version = "0.1.0"
"#,
&output,
)
}
#[test]
fn test_only_edits_stuff() {
let input = r#"
[workspace]
members = ["."]
[package]
something = {some = "something"}
# Some comment
[workspace.package]
version = "0.0.0" # some comment
readme = "../../"
"#;
let output = RustAction::default()
.execute_content(
&semver::Version {
major: 0,
minor: 1,
patch: 0,
pre: Prerelease::default(),
build: BuildMetadata::default(),
},
input,
)
.unwrap();
pretty_assertions::assert_eq!(
r#"
[workspace]
members = ["."]
[package]
something = {some = "something"}
# Some comment
[workspace.package]
version = "0.1.0"
readme = "../../"
"#,
&output,
)
}
}

View File

@ -1,18 +1,12 @@
[package]
name = "cuddle-please-commands"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
readme = "../../README.md"
license-file = "../../LICENSE"
version = "0.1.0"
edition = "2021"
publishable = true
[dependencies]
cuddle-please-frontend.workspace = true
cuddle-please-misc.workspace = true
cuddle-please-actions.workspace = true
anyhow.workspace = true
tracing.workspace = true

View File

@ -6,14 +6,11 @@ use std::{
};
use clap::{Parser, Subcommand};
use cuddle_please_actions::Actions;
use cuddle_please_frontend::{gatheres::ConfigArgs, PleaseConfig, PleaseConfigBuilder};
use cuddle_please_misc::{
ConsoleUi, DynRemoteGitClient, DynUi, GiteaClient, GlobalArgs, LocalGitClient, StdinFn,
VcsClient,
};
use tracing::Level;
use tracing_subscriber::EnvFilter;
use crate::{
config_command::{ConfigCommand, ConfigCommandHandler},
@ -91,62 +88,31 @@ impl Command {
}
pub fn execute(self, current_dir: Option<&Path>) -> anyhow::Result<()> {
if let Some(c) = &self.commands {
match c {
Commands::Release {} => {
let (config, git_client, gitea_client, actions) = self.get_deps(current_dir)?;
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client, actions)
.execute(self.global.dry_run)?;
}
Commands::Config { command } => {
let (config, _, _, _) = self.get_deps(current_dir)?;
ConfigCommandHandler::new(self.ui, config).execute(command)?;
}
Commands::Gitea { command } => {
let (config, _, gitea_client, _) = self.get_deps(current_dir)?;
let config = self.build_config(current_dir)?;
let git_client = self.get_git(&config)?;
let gitea_client = self.get_gitea_client(&config);
GiteaCommandHandler::new(self.ui, config, gitea_client)
.execute(command, self.global.token.expect("token to be set").deref())?;
}
Commands::Doctor {} => {
DoctorCommandHandler::new(self.ui).execute()?;
}
match &self.commands {
Some(Commands::Release {}) => {
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client)
.execute(self.global.dry_run)?;
}
Some(Commands::Config { command }) => {
ConfigCommandHandler::new(self.ui, config).execute(command)?;
}
Some(Commands::Gitea { command }) => {
GiteaCommandHandler::new(self.ui, config, gitea_client)
.execute(command, self.global.token.expect("token to be set").deref())?;
}
Some(Commands::Doctor {}) => {
DoctorCommandHandler::new(self.ui).execute()?;
}
None => {}
}
Ok(())
}
fn get_deps(
&self,
current_dir: Option<&Path>,
) -> anyhow::Result<(PleaseConfig, VcsClient, DynRemoteGitClient, Actions)> {
let config = self.build_config(current_dir)?;
let git_client =
self.get_git(&config, self.global.token.clone().expect("token to be set"))?;
let gitea_client = self.get_gitea_client(&config);
let filter = match self.global.log_level {
cuddle_please_misc::LogLevel::None => None,
cuddle_please_misc::LogLevel::Trace => Some(Level::TRACE),
cuddle_please_misc::LogLevel::Debug => Some(Level::DEBUG),
cuddle_please_misc::LogLevel::Info => Some(Level::INFO),
cuddle_please_misc::LogLevel::Error => Some(Level::ERROR),
};
if let Some(filter) = filter {
let env_filter = EnvFilter::builder().with_regex(false).parse(format!(
"{},hyper=error,reqwest=error,git_cliff_core=error",
filter
))?;
tracing_subscriber::fmt().with_env_filter(env_filter).init();
}
let actions = self.get_actions()?;
Ok((config, git_client, gitea_client, actions))
}
fn build_config(&self, current_dir: Option<&Path>) -> Result<PleaseConfig, anyhow::Error> {
let mut builder = &mut PleaseConfigBuilder::new();
if self.global.config_stdin {
@ -165,7 +131,7 @@ impl Command {
Ok(config)
}
fn get_git(&self, config: &PleaseConfig, token: String) -> anyhow::Result<VcsClient> {
fn get_git(&self, config: &PleaseConfig) -> anyhow::Result<VcsClient> {
if self.global.no_vcs {
Ok(VcsClient::new_noop())
} else {
@ -173,7 +139,6 @@ impl Command {
config.get_source(),
config.settings.git_username.clone(),
config.settings.git_email.clone(),
token,
)
}
}
@ -187,10 +152,6 @@ impl Command {
)),
}
}
fn get_actions(&self) -> anyhow::Result<Actions> {
Actions::from_cuddle()
}
}
#[derive(Debug, Clone, Subcommand)]

View File

@ -1,4 +1,3 @@
use cuddle_please_actions::Actions;
use cuddle_please_frontend::PleaseConfig;
use ::semver::Version;
@ -14,7 +13,6 @@ pub struct ReleaseCommandHandler {
config: PleaseConfig,
git_client: VcsClient,
gitea_client: DynRemoteGitClient,
actions: Actions,
}
impl ReleaseCommandHandler {
@ -23,14 +21,12 @@ impl ReleaseCommandHandler {
config: PleaseConfig,
git_client: VcsClient,
gitea_client: DynRemoteGitClient,
actions: Actions,
) -> Self {
Self {
ui,
config,
git_client,
gitea_client,
actions,
}
}
@ -41,24 +37,15 @@ impl ReleaseCommandHandler {
let branch = self.config.get_branch();
let source = self.config.get_source();
self.ui.write_str_ln("running releaser");
self.check_git_remote_connection(owner, repository)?;
tracing::trace!("connected to git remote");
let significant_tag = self.get_most_significant_tag(owner, repository)?;
tracing::trace!("found lastest release tag");
let commits =
self.fetch_commits_since_last_tag(owner, repository, &significant_tag, branch)?;
tracing::trace!("fetched commits since last version");
let current_version = get_current_version(significant_tag);
tracing::trace!("found current version: {}", current_version.to_string());
self.ui
.write_str_ln(&format!("found current version: {}", current_version));
let conventional_commit_results = parse_conventional_commits(current_version, commits)?;
tracing::trace!("parsing conventional commits");
if conventional_commit_results.is_none() {
tracing::debug!("found no new commits, aborting early");
self.ui
@ -66,19 +53,12 @@ impl ReleaseCommandHandler {
return Ok(());
}
let (commit_strs, next_version) = conventional_commit_results.unwrap();
self.ui
.write_str_ln(&format!("calculated next version: {}", next_version));
tracing::trace!("creating changelog");
let (changelog_placement, changelog, changelog_last_changes) =
compose_changelog(&commit_strs, &next_version, source)?;
self.actions.execute(&next_version)?;
if let Some(first_commit) = commit_strs.first() {
if first_commit.contains("chore(release): ") {
tracing::trace!("creating release");
self.ui.write_str_ln("creating release");
self.create_release(
dry_run,
owner,
@ -91,7 +71,6 @@ impl ReleaseCommandHandler {
}
}
tracing::trace!("creating pull-request");
self.create_pull_request(
changelog_placement,
changelog,
@ -114,7 +93,7 @@ impl ReleaseCommandHandler {
next_version: &Version,
changelog_last_changes: Option<String>,
) -> Result<(), anyhow::Error> {
if !dry_run {
Ok(if !dry_run {
self.gitea_client.create_release(
owner,
repository,
@ -124,8 +103,7 @@ impl ReleaseCommandHandler {
)?;
} else {
tracing::debug!("creating release (dry_run)");
};
Ok(())
})
}
fn create_pull_request(
@ -139,24 +117,18 @@ impl ReleaseCommandHandler {
changelog_last_changes: Option<String>,
branch: &str,
) -> Result<(), anyhow::Error> {
self.ui
.write_str_ln("creating and checking out release branch");
self.git_client.checkout_branch()?;
std::fs::write(changelog_placement, changelog.as_bytes())?;
self.ui.write_str_ln("committed changelog files");
self.git_client
.commit_and_push(next_version.to_string(), dry_run)?;
let _pr_number = match self.gitea_client.get_pull_request(owner, repository)? {
Some(existing_pr) => {
self.ui.write_str_ln("found existing pull request");
self.ui.write_str_ln("updating pull request");
if !dry_run {
self.gitea_client.update_pull_request(
owner,
repository,
&next_version.to_string(),
&changelog_last_changes
.ok_or(anyhow::anyhow!("could not get the latest changes"))?,
&changelog_last_changes.unwrap(),
existing_pr,
)?
} else {
@ -165,14 +137,12 @@ impl ReleaseCommandHandler {
}
}
None => {
self.ui.write_str_ln("creating pull request");
if !dry_run {
self.gitea_client.create_pull_request(
owner,
repository,
&next_version.to_string(),
&changelog_last_changes
.ok_or(anyhow::anyhow!("could not get the latest changes"))?,
&changelog,
branch,
)?
} else {
@ -207,7 +177,7 @@ impl ReleaseCommandHandler {
) -> Result<Option<Tag>, anyhow::Error> {
let tags = self.gitea_client.get_tags(owner, repository)?;
let significant_tag = get_most_significant_version(tags.iter().collect());
Ok(significant_tag.cloned())
Ok(significant_tag.map(|t| t.clone()))
}
fn check_git_remote_connection(
@ -257,7 +227,8 @@ fn parse_conventional_commits(
}
fn get_current_version(significant_tag: Option<Tag>) -> Version {
significant_tag
let current_version = significant_tag
.map(|st| Version::try_from(st).unwrap())
.unwrap_or(Version::new(0, 0, 0))
.unwrap_or(Version::new(0, 0, 0));
current_version
}

View File

@ -1,12 +1,7 @@
[package]
name = "cuddle-please-frontend"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
readme = "../../README.md"
license-file = "../../LICENSE"
version = "0.1.0"
edition = "2021"
publishable = true
[dependencies]
anyhow.workspace = true

View File

@ -30,9 +30,12 @@ const CUDDLE_CONFIG_FILE_NAME: &str = "cuddle.please";
const YAML_EXTENSION: &str = "yaml";
pub fn get_config_from_config_file(current_dir: &Path) -> PleaseConfigBuilder {
let current_cuddle_path = current_dir.join(format!("{CUDDLE_FILE_NAME}.{YAML_EXTENSION}"));
let current_cuddle_config_path =
current_dir.join(format!("{CUDDLE_CONFIG_FILE_NAME}.{YAML_EXTENSION}"));
let current_cuddle_path = current_dir
.clone()
.join(format!("{CUDDLE_FILE_NAME}.{YAML_EXTENSION}"));
let current_cuddle_config_path = current_dir
.clone()
.join(format!("{CUDDLE_CONFIG_FILE_NAME}.{YAML_EXTENSION}"));
let mut please_config = PleaseConfigBuilder::default();
if let Some(config) = get_config_from_file::<CuddleEmbeddedPleaseConfig>(current_cuddle_path) {

View File

@ -1,12 +1,7 @@
[package]
name = "cuddle-please-misc"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
readme = "../../README.md"
license-file = "../../LICENSE"
version = "0.1.0"
edition = "2021"
publishable = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -52,15 +52,6 @@ config-stdin will consume stdin until the channel is closed via. EOF"
default_value = "gitea"
)]
pub engine: RemoteEngine,
#[arg(
env = "CUDDLE_PLEASE_LOG_LEVEL",
long,
global = true,
help_heading = "Global",
default_value = "none"
)]
pub log_level: LogLevel,
}
#[derive(ValueEnum, Clone, Debug)]
@ -68,11 +59,3 @@ pub enum RemoteEngine {
Local,
Gitea,
}
#[derive(ValueEnum, Clone, Debug)]
pub enum LogLevel {
None,
Trace,
Debug,
Info,
Error,
}

View File

@ -3,7 +3,7 @@ use chrono::{DateTime, NaiveDate, Utc};
use git_cliff_core::{
changelog::Changelog,
commit::Commit,
config::{Bump, ChangelogConfig, CommitParser, Config, GitConfig, Remote, RemoteConfig},
config::{ChangelogConfig, CommitParser, Config, GitConfig},
release::Release,
};
use regex::Regex;
@ -77,8 +77,6 @@ impl ChangeLogBuilder {
commit_id: None,
timestamp,
previous: None,
message: None,
repository: None,
},
config: self.config,
release_link: self.release_link,
@ -88,7 +86,7 @@ impl ChangeLogBuilder {
fn release_timestamp(&self) -> i64 {
self.release_date
.and_then(|date| date.and_hms_opt(0, 0, 0))
.map(|d| DateTime::<Utc>::from_naive_utc_and_offset(d, Utc))
.map(|d| DateTime::<Utc>::from_utc(d, Utc))
.unwrap_or_else(Utc::now)
.timestamp()
}
@ -141,8 +139,6 @@ impl ChangeLog<'_> {
let config = Config {
changelog: default_changelog_config(None, self.release_link.as_deref()),
git: default_git_config(),
remote: RemoteConfig::default(),
bump: Bump::default(),
};
config
@ -152,8 +148,6 @@ impl ChangeLog<'_> {
let config = Config {
changelog: default_changelog_config(header, self.release_link.as_deref()),
git: default_git_config(),
remote: RemoteConfig::default(),
bump: Bump::default(),
};
config
@ -179,10 +173,6 @@ fn default_commit_parsers() -> Vec<CommitParser> {
default_scope: None,
scope: None,
skip: None,
field: None,
pattern: None,
sha: None,
footer: None,
}
}
@ -193,7 +183,6 @@ fn default_commit_parsers() -> Vec<CommitParser> {
create_commit_parser("removed", "removed"),
create_commit_parser("fix", "fixed"),
create_commit_parser("security", "security"),
create_commit_parser("docs", "docs"),
CommitParser {
message: Regex::new(".*").ok(),
group: Some(String::from("other")),
@ -201,10 +190,6 @@ fn default_commit_parsers() -> Vec<CommitParser> {
default_scope: None,
skip: None,
scope: None,
field: None,
pattern: None,
sha: None,
footer: None,
},
]
}
@ -224,7 +209,6 @@ fn default_changelog_config(header: Option<String>, release_link: Option<&str>)
body: Some(default_changelog_body_config(release_link)),
footer: None,
trim: Some(true),
postprocessors: None,
}
}

View File

@ -7,7 +7,6 @@ pub enum VcsClient {
source: PathBuf,
username: String,
email: String,
token: String,
},
}
@ -20,7 +19,6 @@ impl VcsClient {
path: &Path,
git_username: Option<impl Into<String>>,
git_email: Option<impl Into<String>>,
git_token: String,
) -> anyhow::Result<VcsClient> {
if !path.to_path_buf().join(".git").exists() {
anyhow::bail!("git directory not found in: {}", path.display().to_string())
@ -34,7 +32,6 @@ impl VcsClient {
email: git_email
.map(|e| e.into())
.unwrap_or("bot@cuddle.sh".to_string()),
token: git_token,
})
}
@ -59,15 +56,10 @@ impl VcsClient {
source,
username,
email,
token,
} => {
let checkout_branch = std::process::Command::new("git")
.current_dir(source.as_path())
.args([
"-c",
&format!("http.extraHeader='Authorization: token {}'", token),
"-c",
"http.extraHeader='Sudo: kjuulh'",
.args(&[
"-c",
&format!("user.name={}", username),
"-c",
@ -79,13 +71,6 @@ impl VcsClient {
let stdout = std::str::from_utf8(&checkout_branch.stdout)?;
let stderr = std::str::from_utf8(&checkout_branch.stderr)?;
tracing::debug!(stdout = stdout, stderr = stderr, "git {}", args.join(" "));
let exit_code = checkout_branch.status;
if !exit_code.success() {
anyhow::bail!(
"failed to run git command: {}",
exit_code.code().unwrap_or(-1)
)
}
}
}

View File

@ -330,7 +330,7 @@ impl RemoteGitEngine for GiteaClient {
base: base.into(),
body: body.into(),
head: "cuddle-please/release".into(),
title: format!("chore(release): v{}", version),
title: format!("chore(release): {}", version),
};
tracing::trace!(
@ -377,7 +377,7 @@ impl RemoteGitEngine for GiteaClient {
let request = CreatePullRequestOption {
body: body.into(),
title: format!("chore(release): v{}", version),
title: format!("chore(release): {}", version),
};
tracing::trace!(
@ -429,9 +429,9 @@ impl RemoteGitEngine for GiteaClient {
let request = CreateReleaseOption {
body: body.into(),
draft: false,
name: format!("v{version}"),
name: version.into(),
prerelease,
tag_name: format!("v{version}"),
tag_name: version.into(),
};
tracing::trace!(
@ -517,7 +517,6 @@ impl TryFrom<Tag> for Version {
tracing::trace!(name = &value.name, "parsing tag into version");
value
.name
.trim_start_matches("v")
.parse::<Version>()
.context("could not get version from tag")
}

View File

@ -6,7 +6,7 @@ mod local_git_client;
mod ui;
mod versioning;
pub use args::{GlobalArgs, LogLevel, RemoteEngine, StdinFn};
pub use args::{GlobalArgs, RemoteEngine, StdinFn};
pub use cliff::{changelog_parser, ChangeLogBuilder};
pub use git_client::VcsClient;
pub use gitea_client::{Commit, DynRemoteGitClient, GiteaClient, RemoteGitEngine, Tag};

View File

@ -1,31 +0,0 @@
[package]
name = "cuddle-please-release-strategy"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
version = "0.1.0"
edition = "2021"
readme = "../../README.md"
license-file = "../../LICENSE"
publishable = true
[dependencies]
anyhow.workspace = true
tracing.workspace = true
serde.workspace = true
semver.workspace = true
[dev-dependencies]
tracing-test = { workspace = true, features = ["no-env-filter"] }
pretty_assertions.workspace = true
tempdir.workspace = true
[features]
rust-workspace = []
rust-crate = []
toml-edit = []
json-edit = []
yaml-edit = []
default = [
"json-edit"
]

View File

@ -1,60 +0,0 @@
use std::path::Path;
use anyhow::Context;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct JsonEditOptions {
pub jq: String,
}
impl JsonEditOptions {
pub fn execute(&self, path: &Path, next_version: impl AsRef<str>) -> anyhow::Result<()> {
let next_version = next_version.as_ref();
if !path.exists() {
anyhow::bail!("could not find file at: {}", path.display());
}
if let Ok(metadata) = path.metadata() {
if !metadata.is_file() {
anyhow::bail!("{} is not a file", path.display());
}
}
let abs_path = path.canonicalize().context(anyhow::anyhow!(
"could not get absolute path from {}",
path.display()
))?;
let output = std::process::Command::new("jq")
.arg("--arg")
.arg("version")
.arg(next_version)
.arg(&self.jq)
.arg(
abs_path
.to_str()
.ok_or(anyhow::anyhow!("path contains non utf-8 chars"))?,
)
.output()
.context(anyhow::anyhow!(
"failed to run jq on file, jq may not be installed or query was invalid"
))?;
if !output.status.success() {
let err_content = std::str::from_utf8(output.stderr.as_slice())?;
anyhow::bail!("failed to run jq with output: {}", err_content);
}
let edited_json_content = std::str::from_utf8(output.stdout.as_slice())?;
tracing::trace!(
new_content = edited_json_content,
file = &abs_path.display().to_string(),
"applied jq to file"
);
std::fs::write(abs_path, edited_json_content)?;
Ok(())
}
}

View File

@ -1,6 +0,0 @@
#[cfg(feature = "json-edit")]
mod json_edit;
mod strategy;
#[cfg(feature = "json-edit")]
pub use json_edit::JsonEditOptions;

View File

@ -1,59 +0,0 @@
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
pub struct UpdateOptions {
next_version: String,
global_changelog: String,
}
pub type Projects = Vec<Project>;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Project {
path: Option<PathBuf>,
r#type: ProjectType,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum ProjectType {
#[cfg(feature = "rust-workspace")]
#[serde(alias = "rust_workspace")]
RustWorkspace,
#[cfg(feature = "rust-crate")]
#[serde(alias = "json_edit")]
RustCrate,
#[cfg(feature = "toml-edit")]
#[serde(alias = "toml_edit")]
TomlEdit,
#[cfg(feature = "yaml-edit")]
#[serde(alias = "yaml_edit")]
YamlEdit,
#[cfg(feature = "json-edit")]
#[serde(alias = "json_edit")]
JsonEdit,
}
impl Project {
pub fn new(path: Option<PathBuf>, r#type: ProjectType) -> Self {
Self { path, r#type }
}
pub fn execute(&self, options: &UpdateOptions) -> anyhow::Result<()> {
match self.r#type {
#[cfg(feature = "rust-workspace")]
ProjectType::RustWorkspace => todo!(),
#[cfg(feature = "rust-crate")]
ProjectType::RustCrate => todo!(),
#[cfg(feature = "toml-edit")]
ProjectType::TomlEdit => todo!(),
#[cfg(feature = "yaml-edit")]
ProjectType::YamlEdit => todo!(),
#[cfg(feature = "json-edit")]
ProjectType::JsonEdit => todo!(),
}
Ok(())
}
}

View File

@ -1,50 +0,0 @@
use tracing_test::traced_test;
#[test]
#[traced_test]
#[cfg(feature = "json-edit")]
pub fn test_can_update_version_in_jq() {
use cuddle_please_release_strategy::JsonEditOptions;
let dir = tempdir::TempDir::new("can_update_version_in_jq").unwrap();
let dir_path = dir.path();
let json_file = dir_path.join("some-test.json");
let initial_content = r#"{
"some": {
"nested": [
{
"structure": {
"version": "v1.0.1"
}
}
]
}
}
"#;
let expected = r#"{
"some": {
"nested": [
{
"structure": {
"version": "v1.0.2"
}
}
]
}
}
"#;
std::fs::write(&json_file, initial_content).unwrap();
let actual_file = std::fs::read_to_string(&json_file).unwrap();
pretty_assertions::assert_eq!(initial_content, actual_file);
let edit_options = JsonEditOptions {
jq: r#".some.nested[].structure.version=$version"#.into(),
};
edit_options.execute(&json_file, "v1.0.2").unwrap();
let actual_file = std::fs::read_to_string(&json_file).unwrap();
pretty_assertions::assert_eq!(expected, &actual_file);
}

View File

@ -1,12 +1,7 @@
[package]
name = "cuddle-please"
description = "A release-please inspired release manager tool, built on top of cuddle, but also useful standalone, cuddle-please supports, your ci of choice, as well as gitea, github"
repository = "https://git.front.kjuulh.io/kjuulh/cuddle-please"
readme = "../../README.md"
license-file = "../../LICENSE"
version = "0.1.0"
edition = "2021"
publishable = true
[dependencies]
cuddle-please-frontend.workspace = true

View File

@ -2,6 +2,7 @@ use cuddle_please_commands::PleaseCommand;
fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();
let current_dir = std::env::current_dir().ok();
let current_dir = current_dir.as_deref();

View File

@ -13,7 +13,6 @@ fn get_base_args<'a>() -> Vec<&'a str> {
"list",
"--no-vcs",
"--engine=local",
"--token=something",
]
}
@ -25,6 +24,7 @@ PleaseConfig
api_url: https://some-example.gitea-instance
"#;
#[test]
#[traced_test]
fn test_config_from_current_dir() {
let args = get_base_args();
@ -38,6 +38,7 @@ fn test_config_from_current_dir() {
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]
#[traced_test]
fn test_config_from_source_dir() {
let mut args = get_base_args();
@ -53,6 +54,7 @@ fn test_config_from_source_dir() {
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]
#[traced_test]
fn test_config_from_stdin() {
let mut args = get_base_args();
@ -72,6 +74,7 @@ settings:
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]
#[traced_test]
fn test_config_fails_when_not_path_is_set() {
let args = get_base_args();

View File

@ -17,8 +17,7 @@ fn exec_git_into_branch() {
add_commit(tempdir.path(), "second").unwrap();
add_tag(tempdir.path(), "1.0.1").unwrap();
let vcs =
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
vcs.checkout_branch().unwrap();
let output = std::process::Command::new("git")
@ -49,8 +48,7 @@ fn add_files_to_commit() {
add_commit(tempdir.path(), "first").unwrap();
add_tag(tempdir.path(), "1.0.0").unwrap();
let vcs =
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
vcs.checkout_branch().unwrap();
std::fs::File::create(tempdir.path().join("changelog")).unwrap();
@ -78,8 +76,7 @@ fn reset_branch() {
add_commit(tempdir.path(), "first").unwrap();
add_tag(tempdir.path(), "1.0.0").unwrap();
let vcs =
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
vcs.checkout_branch().unwrap();
std::fs::File::create(tempdir.path().join("changelog-first")).unwrap();
@ -168,12 +165,6 @@ fn setup_git(path: &Path) -> anyhow::Result<()> {
let stderr = std::str::from_utf8(&output.stderr)?;
tracing::debug!(stdout = stdout, stderr = stderr, "git init");
exec_git(path, &["checkout", "-b", "main"])?;
exec_git(path, &["config", "user.name", "test"])?;
exec_git(path, &["config", "user.email", "test@test.com"])?;
exec_git(path, &["config", "init.defaultBranch", "main"])?;
Ok(())
}

View File

@ -16,23 +16,13 @@ fn test_vcs_get_noop() {
#[traced_test]
fn test_vcs_get_git_found() {
let testdata = get_test_data_path("git-found");
if let Err(e) = std::process::Command::new("git")
.arg("init")
.arg(".")
.current_dir(&testdata)
.output()
{
println!("{e}");
}
return;
let git = VcsClient::new_git(&testdata, None::<String>, None::<String>, "".into()).unwrap();
let git = VcsClient::new_git(&testdata, None::<String>, None::<String>).unwrap();
assert_eq!(
git,
VcsClient::Git {
source: testdata,
username: "cuddle-please".into(),
email: "bot@cuddle.sh".into(),
token: "".into(),
email: "bot@cuddle.sh".into()
}
)
}

View File

@ -5,9 +5,7 @@ base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
vars:
service: "cuddle-please"
registry: kasperhermansen
mkdocs_image: "squidfunk/mkdocs-material:9.1"
caddy_image: "caddy:2.7"
please:
project:
@ -16,34 +14,10 @@ please:
branch: main
settings:
api_url: https://git.front.kjuulh.io
actions:
rust:
components:
packages:
debian:
dev:
- jq
- git
release:
- jq
- git
scripts:
"mkdocs:new":
type: shell
"mkdocs:dev":
type: shell
"mkdocs:build":
type: shell
"local:docker":
type: shell
"local:docker:docs":
type: shell
"ci:main":
type: shell
"ci:pr":
type: shell
"ci:release":
type: shell

View File

@ -1,81 +0,0 @@
# Configuration
`cuddle-please` requires configuration to function, it is quite flexible, and tries to help you as much as possible filling out values for you, or using sane defaults.
First of all, you can either use the `cuddle.yaml` if using `cuddle`, or `cuddle.please.yaml` if using standalone.
```yaml
# file: cuddle.yaml
please:
<contents of cuddle.please.yaml>
---
# file: cuddle.please.yaml
project:
owner: kjuulh
repository: cuddle-please
branch: main
settings:
api_url: https://git.front.kjuulh.io
```
This is all the configuration, most of these won't be needed when running in CI.
`cuddle` fetches configuration items from different sources, each level is able to override the previous layer.
1. Execution environment
2. Configuration files
3. Stdin
4. Env variables
5. Cli arguments
6. User input
Lets break each down.
### Execution environment
Execution environment, is the environment under which cuddle-please is run, if running in CI, we're able to take some variables, without requiring input from the user, or configuration values.
Right now only `drone-ci` is supported, but github actions and such, are nearly done.
#### Drone CI
Drone CI, will automatically fill out
```yaml
project:
owner: <drone>
repository: <drone>
branch: <drone>
```
This means that the only thing the user needs to configure is the `api_url` and the access `<token>`
### Configuration files
Already shown above, this allows setting hard-coded values, especially useful for the `api_url`.
### Stdin
All the configurations can be passed via. stdin
```bash
cat cuddle.please.yaml | cuddle-please release --stdin
```
### Env variables
The CLI shows which env variables are available via. `cuddle-please release --help`.
### CLI args
The CLI shows which args are available via. `cuddle-please release -h # or --help`
`-h` gives a shorthand description and `--help` provides a longer explanation of each arg.
There are some args, which are exclusive to the cli or env variables, such as `<token>`. This is because it is a secret and it shouldn't be leaked in the configuration. There are some exceptions such as `GITHUB_TOKEN` which is picked in the environment variable layer.
### Interactive (User input)
cuddle-please will determine whether or not it is running with a user interactive `stdin`, and will prompt for missing values if running locally. This is disabled without a proper tty, or if running in one of the CI execution environments by default. Otherwise `--no-interactive` can be passed to any command.

View File

@ -1,156 +0,0 @@
# Getting started
`cuddle-please` is a tool to manage releases in a git repository.
It is either run manually or in ci. To get the most correct behavior
`cuddle-please` should be run on each commit on your primary branch
(main/master).
## Install
First you need the executable
```bash
cargo install cuddle-please
```
or docker (not public yet)
```bash
docker run -v $PWD:/mnt/src -e CUDDLE_PLEASE_TOKEN=<token> kjuulh/cuddle-please:latest
```
!!! warning
Other distributions to be added.
## Configuration
`cuddle-please` requires configuration to function, it is quite flexible, and
tries to help you as much as possible filling out values for you, or using sane
defaults.
For this `getting-started` guide, we will use cli args, but see
[configuration](configuration.md) for all the other options, both manual,
automatic, and interactive.
## Running
First make sure you're on your release branch, this is likely either `main` or
`master`.
```bash
git checkout main
cuddle-please release \
--engine gitea \
--owner kjuulh \
--repository cuddle-please \
--branch main
--api-url 'https://git.front.kjuulh.io/kjuulh/cuddle-please' \
--token <personal-access-token> \
--dry-run
```
We use `gitea` backend here, but you can either leave it out (as it is default
gitea), or set it to github (once that is done).
The token needs to have write access to your repository, as well as the api.
(guide tbd).
Dry-run is used here to not commit any changes to your backend, it may still
change your local git setup, but not the backends. Simply remove the arg if you
want to commit.
!!! note
`--token` can also be set with
`export CUDDLE_PLEASE_TOKEN='<personal-access-token>'` if you don't want to leak the secret to your cli history.
When run you should get output that it has created a dry_run pull-request,
meaning that it was supposed to do the action but didn't commit it.
If you've used versioning previously in your repository, i.e. a tag with
`v1.0.0` or `1.0.0` it will use that to bump the commits based on
[conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) and
[keep a changelog](https://keepachangelog.com/en/1.1.0/).
Changelog generation can be disabled with `--no-changelog`.
### Merging the pr.
If you've created the pull-request (i.e. with the dry-run arg). You can simply
just go to the pull-request and squash merge it.
```bash
# showing the command again, now without --dry-run
# you were automatically moved to cuddle-please/release when running the above command
git checkout main
cuddle-please release \
--engine gitea \
--owner kjuulh \
--repository cuddle-please \
--branch main
--api-url 'https://git.front.kjuulh.io/kjuulh/cuddle-please' \
--token <personal-access-token>
```
It is quite important that the title of the release commit is
`chore(release): <something>`. `<something>` will be the version of the release.
When it is merged, simply update the local repository and run the same command
as above.
```bash
# you were automatically moved to cuddle-please/release when running the above command
git checkout main
git pull origin main
cuddle-please release \
--engine gitea \
--owner kjuulh \
--repository cuddle-please \
--branch main
--api-url 'https://git.front.kjuulh.io/kjuulh/cuddle-please' \
--token <personal-access-token> \
```
You should now see a release artifact in the releases page, as well as a tag
with the version.
### Running in CI.
Cuddle-please shines the best when running in CI, as we're able to pull most
variables from that, such as `owner`, `repository`, `branch`, etc.
To run in ci see [continuous-integration](continuous-integration.md) for all the
different platforms.
Below is a snippet showing a `drone-ci` setup
```yaml
kind: pipeline
name: cuddle-please-release
type: docker
steps:
- name: cuddle-please release
image: docker.io/kjuulh/cuddle-please:v0.1.0
commands:
- cuddle-please release
environment:
CUDDLE_PLEASE_TOKEN:
from_secret: cuddle-please-token
CUDDLE_PLEASE_API_URL: "https://git.front.kjuulh.io"
when:
branch:
- main
- master
```
All the other options will automatically be pulled from the drone environment.
Throughts its own
[runtime configuration](https://docs.drone.io/pipeline/environment/reference/).
Right now only drone is supported with these fetch features, Please open an
issue, if you have another environment you'd like to run in. Such as github
actions, circleci, etc.

View File

@ -1,35 +1,17 @@
# Cuddle docs
# Welcome to MkDocs
Cuddle Please is an extension to `cuddle`, it is a separate binary that can be executed standalone as `cuddle-please`, or in cuddle as `cuddle please`.
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
The goal of the software is to be a `release-please` clone, targeting `gitea` instead of `github`.
## Commands
The tool can be executed as a binary using:
* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.
```bash
cuddle please release # if using cuddle
# or
cuddle-please release # if using standalone
```
## Project layout
And when a release has been built:
```bash
cuddle please release
# or
cuddle-please release
```
cuddle will default to information to it available in git, or use a specific entry in `cuddle.yaml` called
```yaml
# ...
please:
name: <something>
# ...
# ...
```
or as `cuddle.please.yaml`
See docs for more information about installation and some such
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.

View File

@ -1,29 +0,0 @@
# Installation
## Cargo version
```bash
cargo install cuddle-please
# or
cargo binstall cuddle-please # if using binstall
```
More to come as the project matures.
## Development version
### Cuddle
[Cuddle](https://git.front.kjuulh.io/kjuulh/cuddle) is a script and configuration management tool, it is by far the easiest approach for building the development version of cuddle-please, but optional.
```bash
cuddle x build:release
# or docker
cuddle x build:docker:release
```
### Cargo
```bash
cargo build --release -p cuddle_cli
```

View File

@ -19,7 +19,3 @@ theme:
toggle:
icon: material/brightness-4
name: Switch to light mode # Palette toggle for light mode
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences

View File

@ -1,17 +0,0 @@
#!/usr/bin/env bash
set -e
CMD_PREFIX="cargo run -p ci --"
if [[ -n "$CI_PREFIX" ]]; then
CMD_PREFIX="$CI_PREFIX"
fi
$CMD_PREFIX main \
--mkdocs-image "$MKDOCS_IMAGE" \
--caddy-image "$CADDY_IMAGE" \
--image "$REGISTRY/$SERVICE" \
--tag "main-$(date +%s)" \
--bin-name "$SERVICE"

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -e
CMD_PREFIX="cargo run -p ci --"
if [[ -n "$CI_PREFIX" ]]; then
CMD_PREFIX="$CI_PREFIX"
fi
$CMD_PREFIX pull-request \
--mkdocs-image "$MKDOCS_IMAGE" \
--caddy-image "$CADDY_IMAGE" \
--bin-name "$SERVICE"

View File

@ -1,17 +0,0 @@
#!/usr/bin/env bash
set -e
CMD_PREFIX="cargo run -p ci --"
if [[ -n "$CI_PREFIX" ]]; then
CMD_PREFIX="$CI_PREFIX"
fi
$CMD_PREFIX release \
--mkdocs-image "$MKDOCS_IMAGE" \
--caddy-image "$CADDY_IMAGE" \
--image "$REGISTRY/$SERVICE" \
--tag "$DRONE_TAG" \
--bin-name "$SERVICE"

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -e
cargo run -p ci -- local docker-image --image kasperhermansen/cuddle-please --tag dev --bin-name cuddle-please

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -e
cargo run -p ci -- local build-docs --mkdocs-image $MKDOCS_IMAGE --caddy-image $CADDY_IMAGE

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -e
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs ${MKDOCS_IMAGE}

View File

@ -1 +0,0 @@

View File

@ -1,8 +0,0 @@
{
debug
}
http://blog.kasperhermansen.com {
root * /usr/share/caddy
file_server
}