Compare commits
114 Commits
Author | SHA1 | Date | |
---|---|---|---|
545e8c5476 | |||
42f23fdfac | |||
249a40f1aa | |||
c1187022f2 | |||
0fc1438a4a | |||
166be0c289 | |||
|
ff9f5e25d2 | ||
9ac744b39d | |||
9c967a0f31 | |||
3878e6bc0a | |||
|
9999fca9b0 | ||
dad8fc472e | |||
05ecdf5251 | |||
12063f7c23 | |||
490130126b | |||
9201ff9294 | |||
477d82af55 | |||
d94b9cbe86 | |||
2b277ec61f | |||
3f2642aed0 | |||
44bc26de93 | |||
013bf3b3dc | |||
497ae0f19d | |||
2dcd9d0cd1 | |||
a0634a542b | |||
036998b0b9 | |||
e92284002a | |||
69f64bdab2 | |||
f624109643 | |||
2404a14a32 | |||
9a5396a81e | |||
ae0a54db69 | |||
8e36f2a3ca | |||
|
384e575758 | ||
850ada11c2 | |||
56d33e2ca5 | |||
d64a1d15dc | |||
c2e0b548f6 | |||
51ca73a53b | |||
675947ed1e | |||
bf3593eee4 | |||
19d748702a | |||
4276f4529c | |||
d287a54cdf | |||
7baf51c1f2 | |||
56b44cf2e2 | |||
2919ca9a04 | |||
ff2b59dd02 | |||
19dd0ff636 | |||
c08918ad6f | |||
19e7adfedb | |||
27cb31f433 | |||
113e5282ef | |||
fa67dfeee3 | |||
8a8d309ddf | |||
09508ec986 | |||
0967e35fbf | |||
67c2c0c0c5 | |||
78307ec8a3 | |||
d6e6dcb032 | |||
0a7cbae91d | |||
f94677d78f | |||
2d255c21e6 | |||
8d26c861cc | |||
7d71ad7865 | |||
a0b71c66ad | |||
358027c850 | |||
6f694fa0b0 | |||
914c41f3d5 | |||
6c3aca4c29 | |||
14ccba6a7e | |||
4c7ea7dae6 | |||
b00cb42208 | |||
7000d4e2a6 | |||
aa00836a29 | |||
e7cb032afb | |||
5674b6795c | |||
20f2392b4a | |||
ab1fc6d9c0 | |||
628e842988 | |||
9e125f08e8 | |||
22bf047d9c | |||
6703e9c58f | |||
64f8e427e6 | |||
ae14ba84c2 | |||
49a9c9f2d4 | |||
7a984f0692 | |||
0a7a924727 | |||
5dce2e4790 | |||
be27bcfbcd | |||
b23ca68c62 | |||
cf7c006637 | |||
e669434620 | |||
be2f9f8330 | |||
34417f77bc | |||
8ee05136df | |||
f7d02bad10 | |||
5c205d1ac1 | |||
af821a9d3a | |||
c131ebdb7e | |||
59ea3603a2 | |||
8449ba4735 | |||
5b1e622434 | |||
86f96460ee | |||
decdf5f777 | |||
f7a6ea5d83 | |||
b6af2378c3 | |||
0a3c5671d5 | |||
391defa4ee | |||
b4acb55d0c | |||
f75e839759 | |||
84cc24e81c | |||
808f88b8f6 | |||
8db6fc9d75 |
2
.drone.yml
Normal file
2
.drone.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
kind: template
|
||||||
|
load: cuddle-rust-cli-plan.yaml
|
138
CHANGELOG.md
138
CHANGELOG.md
@ -6,6 +6,144 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [0.1.0] - 2023-08-01
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
1504
Cargo.lock
generated
1504
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
43
Cargo.toml
43
Cargo.toml
@ -1,30 +1,39 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/cuddle-please", "crates/cuddle-please-frontend", "crates/cuddle-please-commands", "crates/cuddle-please-misc"]
|
members = [
|
||||||
|
"crates/*"
|
||||||
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
cuddle-please = { path = "crates/cuddle-please" }
|
cuddle-please = { path = "crates/cuddle-please", version = "0.1.0" }
|
||||||
cuddle-please-frontend = { path = "crates/cuddle-please-frontend" }
|
cuddle-please-frontend = { path = "crates/cuddle-please-frontend", version = "0.1.0" }
|
||||||
cuddle-please-commands = { path = "crates/cuddle-please-commands" }
|
cuddle-please-commands = { path = "crates/cuddle-please-commands", version = "0.1.0" }
|
||||||
cuddle-please-misc = { path = "crates/cuddle-please-misc" }
|
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" }
|
||||||
|
|
||||||
anyhow = { version = "1.0.72" }
|
anyhow = { version = "1.0.81" }
|
||||||
tracing = { version = "0.1", features = ["log"] }
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
tracing-subscriber = { version = "0.3.17" }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
clap = { version = "4.3.19", features = ["derive", "env"] }
|
clap = { version = "4.5.4", features = ["derive", "env"] }
|
||||||
dotenv = { version = "0.15.0" }
|
dotenv = { version = "0.15.0" }
|
||||||
url = { version = "2.4.0" }
|
url = { version = "2.5.0" }
|
||||||
serde_yaml = { version = "0.9.25" }
|
serde_yaml = { version = "0.9.34+deprecated" }
|
||||||
|
yaml-rust2 = {version = "0.8.0"}
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
semver = "1.0.18"
|
semver = "1.0.22"
|
||||||
conventional_commit_parser = "0.9.4"
|
conventional_commit_parser = "0.9.4"
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
reqwest = { version = "0.11.18" }
|
reqwest = { version = "0.12.3" }
|
||||||
git-cliff-core = "1.2.0"
|
git-cliff-core = "2.2.0"
|
||||||
regex = "*"
|
regex = "1.10.4"
|
||||||
chrono = "*"
|
chrono = "0.4.37"
|
||||||
lazy_static = "*"
|
lazy_static = "1.4.0"
|
||||||
parse-changelog = "*"
|
parse-changelog = "0.6.6"
|
||||||
|
toml_edit = "0.22.9"
|
||||||
|
|
||||||
tracing-test = "0.2"
|
tracing-test = "0.2"
|
||||||
pretty_assertions = "1.4"
|
pretty_assertions = "1.4"
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
|
version = "0.5.0"
|
||||||
|
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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.
|
24
README.md
24
README.md
@ -36,32 +36,16 @@ See docs for more information about installation and some such
|
|||||||
|
|
||||||
## Checklist
|
## 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
|
### 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)
|
- [ ] Add inquire for missing values when needed (when not running in ci or have a proper tty)
|
||||||
- [ ] Break down cuddle-please-misc
|
- [ ] Break down cuddle-please-misc
|
||||||
|
- [ ] ci(release): Add cuddle-please release artifacts for the different os and so on.
|
||||||
|
|
||||||
### 0.x Milestone
|
### 0.x Milestone
|
||||||
- [ ] Add github support
|
- [ ] Add github support
|
||||||
- [ ] Add custom strategies
|
- [ ] Add custom strategies
|
||||||
- [ ] Create docker image
|
|
||||||
- [ ] Add more granular tests
|
- [ ] Add more granular tests
|
||||||
|
19
crates/cuddle-please-actions/Cargo.toml
Normal file
19
crates/cuddle-please-actions/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[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
|
9
crates/cuddle-please-actions/src/actions.rs
Normal file
9
crates/cuddle-please-actions/src/actions.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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<()>;
|
||||||
|
}
|
49
crates/cuddle-please-actions/src/config.rs
Normal file
49
crates/cuddle-please-actions/src/config.rs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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())
|
||||||
|
}
|
||||||
|
}
|
45
crates/cuddle-please-actions/src/lib.rs
Normal file
45
crates/cuddle-please-actions/src/lib.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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(())
|
||||||
|
}
|
||||||
|
}
|
237
crates/cuddle-please-actions/src/rust_action.rs
Normal file
237
crates/cuddle-please-actions/src/rust_action.rs
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
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,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cuddle-please-commands"
|
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"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
publishable = true
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuddle-please-frontend.workspace = true
|
cuddle-please-frontend.workspace = true
|
||||||
cuddle-please-misc.workspace = true
|
cuddle-please-misc.workspace = true
|
||||||
|
cuddle-please-actions.workspace = true
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
@ -6,11 +6,14 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
use cuddle_please_actions::Actions;
|
||||||
use cuddle_please_frontend::{gatheres::ConfigArgs, PleaseConfig, PleaseConfigBuilder};
|
use cuddle_please_frontend::{gatheres::ConfigArgs, PleaseConfig, PleaseConfigBuilder};
|
||||||
use cuddle_please_misc::{
|
use cuddle_please_misc::{
|
||||||
ConsoleUi, DynRemoteGitClient, DynUi, GiteaClient, GlobalArgs, LocalGitClient, StdinFn,
|
ConsoleUi, DynRemoteGitClient, DynUi, GiteaClient, GlobalArgs, LocalGitClient, StdinFn,
|
||||||
VcsClient,
|
VcsClient,
|
||||||
};
|
};
|
||||||
|
use tracing::Level;
|
||||||
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config_command::{ConfigCommand, ConfigCommandHandler},
|
config_command::{ConfigCommand, ConfigCommandHandler},
|
||||||
@ -88,31 +91,62 @@ impl Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(self, current_dir: Option<&Path>) -> anyhow::Result<()> {
|
pub fn execute(self, current_dir: Option<&Path>) -> anyhow::Result<()> {
|
||||||
let config = self.build_config(current_dir)?;
|
if let Some(c) = &self.commands {
|
||||||
let git_client = self.get_git(&config)?;
|
match c {
|
||||||
let gitea_client = self.get_gitea_client(&config);
|
Commands::Release {} => {
|
||||||
|
let (config, git_client, gitea_client, actions) = self.get_deps(current_dir)?;
|
||||||
match &self.commands {
|
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client, actions)
|
||||||
Some(Commands::Release {}) => {
|
|
||||||
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client)
|
|
||||||
.execute(self.global.dry_run)?;
|
.execute(self.global.dry_run)?;
|
||||||
}
|
}
|
||||||
Some(Commands::Config { command }) => {
|
Commands::Config { command } => {
|
||||||
|
let (config, _, _, _) = self.get_deps(current_dir)?;
|
||||||
ConfigCommandHandler::new(self.ui, config).execute(command)?;
|
ConfigCommandHandler::new(self.ui, config).execute(command)?;
|
||||||
}
|
}
|
||||||
Some(Commands::Gitea { command }) => {
|
Commands::Gitea { command } => {
|
||||||
|
let (config, _, gitea_client, _) = self.get_deps(current_dir)?;
|
||||||
|
|
||||||
GiteaCommandHandler::new(self.ui, config, gitea_client)
|
GiteaCommandHandler::new(self.ui, config, gitea_client)
|
||||||
.execute(command, self.global.token.expect("token to be set").deref())?;
|
.execute(command, self.global.token.expect("token to be set").deref())?;
|
||||||
}
|
}
|
||||||
Some(Commands::Doctor {}) => {
|
Commands::Doctor {} => {
|
||||||
DoctorCommandHandler::new(self.ui).execute()?;
|
DoctorCommandHandler::new(self.ui).execute()?;
|
||||||
}
|
}
|
||||||
None => {}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
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> {
|
fn build_config(&self, current_dir: Option<&Path>) -> Result<PleaseConfig, anyhow::Error> {
|
||||||
let mut builder = &mut PleaseConfigBuilder::new();
|
let mut builder = &mut PleaseConfigBuilder::new();
|
||||||
if self.global.config_stdin {
|
if self.global.config_stdin {
|
||||||
@ -131,7 +165,7 @@ impl Command {
|
|||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_git(&self, config: &PleaseConfig) -> anyhow::Result<VcsClient> {
|
fn get_git(&self, config: &PleaseConfig, token: String) -> anyhow::Result<VcsClient> {
|
||||||
if self.global.no_vcs {
|
if self.global.no_vcs {
|
||||||
Ok(VcsClient::new_noop())
|
Ok(VcsClient::new_noop())
|
||||||
} else {
|
} else {
|
||||||
@ -139,6 +173,7 @@ impl Command {
|
|||||||
config.get_source(),
|
config.get_source(),
|
||||||
config.settings.git_username.clone(),
|
config.settings.git_username.clone(),
|
||||||
config.settings.git_email.clone(),
|
config.settings.git_email.clone(),
|
||||||
|
token,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,6 +187,10 @@ impl Command {
|
|||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_actions(&self) -> anyhow::Result<Actions> {
|
||||||
|
Actions::from_cuddle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use cuddle_please_actions::Actions;
|
||||||
use cuddle_please_frontend::PleaseConfig;
|
use cuddle_please_frontend::PleaseConfig;
|
||||||
|
|
||||||
use ::semver::Version;
|
use ::semver::Version;
|
||||||
@ -13,6 +14,7 @@ pub struct ReleaseCommandHandler {
|
|||||||
config: PleaseConfig,
|
config: PleaseConfig,
|
||||||
git_client: VcsClient,
|
git_client: VcsClient,
|
||||||
gitea_client: DynRemoteGitClient,
|
gitea_client: DynRemoteGitClient,
|
||||||
|
actions: Actions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReleaseCommandHandler {
|
impl ReleaseCommandHandler {
|
||||||
@ -21,12 +23,14 @@ impl ReleaseCommandHandler {
|
|||||||
config: PleaseConfig,
|
config: PleaseConfig,
|
||||||
git_client: VcsClient,
|
git_client: VcsClient,
|
||||||
gitea_client: DynRemoteGitClient,
|
gitea_client: DynRemoteGitClient,
|
||||||
|
actions: Actions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
ui,
|
ui,
|
||||||
config,
|
config,
|
||||||
git_client,
|
git_client,
|
||||||
gitea_client,
|
gitea_client,
|
||||||
|
actions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,15 +41,24 @@ impl ReleaseCommandHandler {
|
|||||||
let branch = self.config.get_branch();
|
let branch = self.config.get_branch();
|
||||||
let source = self.config.get_source();
|
let source = self.config.get_source();
|
||||||
|
|
||||||
|
self.ui.write_str_ln("running releaser");
|
||||||
|
|
||||||
self.check_git_remote_connection(owner, repository)?;
|
self.check_git_remote_connection(owner, repository)?;
|
||||||
|
tracing::trace!("connected to git remote");
|
||||||
|
|
||||||
let significant_tag = self.get_most_significant_tag(owner, repository)?;
|
let significant_tag = self.get_most_significant_tag(owner, repository)?;
|
||||||
|
tracing::trace!("found lastest release tag");
|
||||||
|
|
||||||
let commits =
|
let commits =
|
||||||
self.fetch_commits_since_last_tag(owner, repository, &significant_tag, branch)?;
|
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);
|
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)?;
|
let conventional_commit_results = parse_conventional_commits(current_version, commits)?;
|
||||||
|
tracing::trace!("parsing conventional commits");
|
||||||
if conventional_commit_results.is_none() {
|
if conventional_commit_results.is_none() {
|
||||||
tracing::debug!("found no new commits, aborting early");
|
tracing::debug!("found no new commits, aborting early");
|
||||||
self.ui
|
self.ui
|
||||||
@ -53,12 +66,19 @@ impl ReleaseCommandHandler {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let (commit_strs, next_version) = conventional_commit_results.unwrap();
|
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) =
|
let (changelog_placement, changelog, changelog_last_changes) =
|
||||||
compose_changelog(&commit_strs, &next_version, source)?;
|
compose_changelog(&commit_strs, &next_version, source)?;
|
||||||
|
|
||||||
|
self.actions.execute(&next_version)?;
|
||||||
|
|
||||||
if let Some(first_commit) = commit_strs.first() {
|
if let Some(first_commit) = commit_strs.first() {
|
||||||
if first_commit.contains("chore(release): ") {
|
if first_commit.contains("chore(release): ") {
|
||||||
|
tracing::trace!("creating release");
|
||||||
|
self.ui.write_str_ln("creating release");
|
||||||
self.create_release(
|
self.create_release(
|
||||||
dry_run,
|
dry_run,
|
||||||
owner,
|
owner,
|
||||||
@ -71,6 +91,7 @@ impl ReleaseCommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracing::trace!("creating pull-request");
|
||||||
self.create_pull_request(
|
self.create_pull_request(
|
||||||
changelog_placement,
|
changelog_placement,
|
||||||
changelog,
|
changelog,
|
||||||
@ -93,7 +114,7 @@ impl ReleaseCommandHandler {
|
|||||||
next_version: &Version,
|
next_version: &Version,
|
||||||
changelog_last_changes: Option<String>,
|
changelog_last_changes: Option<String>,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
Ok(if !dry_run {
|
if !dry_run {
|
||||||
self.gitea_client.create_release(
|
self.gitea_client.create_release(
|
||||||
owner,
|
owner,
|
||||||
repository,
|
repository,
|
||||||
@ -103,7 +124,8 @@ impl ReleaseCommandHandler {
|
|||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!("creating release (dry_run)");
|
tracing::debug!("creating release (dry_run)");
|
||||||
})
|
};
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_pull_request(
|
fn create_pull_request(
|
||||||
@ -117,18 +139,24 @@ impl ReleaseCommandHandler {
|
|||||||
changelog_last_changes: Option<String>,
|
changelog_last_changes: Option<String>,
|
||||||
branch: &str,
|
branch: &str,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
|
self.ui
|
||||||
|
.write_str_ln("creating and checking out release branch");
|
||||||
self.git_client.checkout_branch()?;
|
self.git_client.checkout_branch()?;
|
||||||
std::fs::write(changelog_placement, changelog.as_bytes())?;
|
std::fs::write(changelog_placement, changelog.as_bytes())?;
|
||||||
|
self.ui.write_str_ln("committed changelog files");
|
||||||
self.git_client
|
self.git_client
|
||||||
.commit_and_push(next_version.to_string(), dry_run)?;
|
.commit_and_push(next_version.to_string(), dry_run)?;
|
||||||
let _pr_number = match self.gitea_client.get_pull_request(owner, repository)? {
|
let _pr_number = match self.gitea_client.get_pull_request(owner, repository)? {
|
||||||
Some(existing_pr) => {
|
Some(existing_pr) => {
|
||||||
|
self.ui.write_str_ln("found existing pull request");
|
||||||
|
self.ui.write_str_ln("updating pull request");
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
self.gitea_client.update_pull_request(
|
self.gitea_client.update_pull_request(
|
||||||
owner,
|
owner,
|
||||||
repository,
|
repository,
|
||||||
&next_version.to_string(),
|
&next_version.to_string(),
|
||||||
&changelog_last_changes.unwrap(),
|
&changelog_last_changes
|
||||||
|
.ok_or(anyhow::anyhow!("could not get the latest changes"))?,
|
||||||
existing_pr,
|
existing_pr,
|
||||||
)?
|
)?
|
||||||
} else {
|
} else {
|
||||||
@ -137,12 +165,14 @@ impl ReleaseCommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
self.ui.write_str_ln("creating pull request");
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
self.gitea_client.create_pull_request(
|
self.gitea_client.create_pull_request(
|
||||||
owner,
|
owner,
|
||||||
repository,
|
repository,
|
||||||
&next_version.to_string(),
|
&next_version.to_string(),
|
||||||
&changelog,
|
&changelog_last_changes
|
||||||
|
.ok_or(anyhow::anyhow!("could not get the latest changes"))?,
|
||||||
branch,
|
branch,
|
||||||
)?
|
)?
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +207,7 @@ impl ReleaseCommandHandler {
|
|||||||
) -> Result<Option<Tag>, anyhow::Error> {
|
) -> Result<Option<Tag>, anyhow::Error> {
|
||||||
let tags = self.gitea_client.get_tags(owner, repository)?;
|
let tags = self.gitea_client.get_tags(owner, repository)?;
|
||||||
let significant_tag = get_most_significant_version(tags.iter().collect());
|
let significant_tag = get_most_significant_version(tags.iter().collect());
|
||||||
Ok(significant_tag.map(|t| t.clone()))
|
Ok(significant_tag.cloned())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_git_remote_connection(
|
fn check_git_remote_connection(
|
||||||
@ -227,8 +257,7 @@ fn parse_conventional_commits(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_version(significant_tag: Option<Tag>) -> Version {
|
fn get_current_version(significant_tag: Option<Tag>) -> Version {
|
||||||
let current_version = significant_tag
|
significant_tag
|
||||||
.map(|st| Version::try_from(st).unwrap())
|
.map(|st| Version::try_from(st).unwrap())
|
||||||
.unwrap_or(Version::new(0, 0, 0));
|
.unwrap_or(Version::new(0, 0, 0))
|
||||||
current_version
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cuddle-please-frontend"
|
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"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
publishable = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -30,12 +30,9 @@ const CUDDLE_CONFIG_FILE_NAME: &str = "cuddle.please";
|
|||||||
const YAML_EXTENSION: &str = "yaml";
|
const YAML_EXTENSION: &str = "yaml";
|
||||||
|
|
||||||
pub fn get_config_from_config_file(current_dir: &Path) -> PleaseConfigBuilder {
|
pub fn get_config_from_config_file(current_dir: &Path) -> PleaseConfigBuilder {
|
||||||
let current_cuddle_path = current_dir
|
let current_cuddle_path = current_dir.join(format!("{CUDDLE_FILE_NAME}.{YAML_EXTENSION}"));
|
||||||
.clone()
|
let current_cuddle_config_path =
|
||||||
.join(format!("{CUDDLE_FILE_NAME}.{YAML_EXTENSION}"));
|
current_dir.join(format!("{CUDDLE_CONFIG_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();
|
let mut please_config = PleaseConfigBuilder::default();
|
||||||
|
|
||||||
if let Some(config) = get_config_from_file::<CuddleEmbeddedPleaseConfig>(current_cuddle_path) {
|
if let Some(config) = get_config_from_file::<CuddleEmbeddedPleaseConfig>(current_cuddle_path) {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cuddle-please-misc"
|
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"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
publishable = true
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
@ -52,6 +52,15 @@ config-stdin will consume stdin until the channel is closed via. EOF"
|
|||||||
default_value = "gitea"
|
default_value = "gitea"
|
||||||
)]
|
)]
|
||||||
pub engine: RemoteEngine,
|
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)]
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
@ -59,3 +68,11 @@ pub enum RemoteEngine {
|
|||||||
Local,
|
Local,
|
||||||
Gitea,
|
Gitea,
|
||||||
}
|
}
|
||||||
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
|
pub enum LogLevel {
|
||||||
|
None,
|
||||||
|
Trace,
|
||||||
|
Debug,
|
||||||
|
Info,
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@ use chrono::{DateTime, NaiveDate, Utc};
|
|||||||
use git_cliff_core::{
|
use git_cliff_core::{
|
||||||
changelog::Changelog,
|
changelog::Changelog,
|
||||||
commit::Commit,
|
commit::Commit,
|
||||||
config::{ChangelogConfig, CommitParser, Config, GitConfig},
|
config::{Bump, ChangelogConfig, CommitParser, Config, GitConfig, Remote, RemoteConfig},
|
||||||
release::Release,
|
release::Release,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -77,6 +77,8 @@ impl ChangeLogBuilder {
|
|||||||
commit_id: None,
|
commit_id: None,
|
||||||
timestamp,
|
timestamp,
|
||||||
previous: None,
|
previous: None,
|
||||||
|
message: None,
|
||||||
|
repository: None,
|
||||||
},
|
},
|
||||||
config: self.config,
|
config: self.config,
|
||||||
release_link: self.release_link,
|
release_link: self.release_link,
|
||||||
@ -86,7 +88,7 @@ impl ChangeLogBuilder {
|
|||||||
fn release_timestamp(&self) -> i64 {
|
fn release_timestamp(&self) -> i64 {
|
||||||
self.release_date
|
self.release_date
|
||||||
.and_then(|date| date.and_hms_opt(0, 0, 0))
|
.and_then(|date| date.and_hms_opt(0, 0, 0))
|
||||||
.map(|d| DateTime::<Utc>::from_utc(d, Utc))
|
.map(|d| DateTime::<Utc>::from_naive_utc_and_offset(d, Utc))
|
||||||
.unwrap_or_else(Utc::now)
|
.unwrap_or_else(Utc::now)
|
||||||
.timestamp()
|
.timestamp()
|
||||||
}
|
}
|
||||||
@ -139,6 +141,8 @@ impl ChangeLog<'_> {
|
|||||||
let config = Config {
|
let config = Config {
|
||||||
changelog: default_changelog_config(None, self.release_link.as_deref()),
|
changelog: default_changelog_config(None, self.release_link.as_deref()),
|
||||||
git: default_git_config(),
|
git: default_git_config(),
|
||||||
|
remote: RemoteConfig::default(),
|
||||||
|
bump: Bump::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
config
|
config
|
||||||
@ -148,6 +152,8 @@ impl ChangeLog<'_> {
|
|||||||
let config = Config {
|
let config = Config {
|
||||||
changelog: default_changelog_config(header, self.release_link.as_deref()),
|
changelog: default_changelog_config(header, self.release_link.as_deref()),
|
||||||
git: default_git_config(),
|
git: default_git_config(),
|
||||||
|
remote: RemoteConfig::default(),
|
||||||
|
bump: Bump::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
config
|
config
|
||||||
@ -173,6 +179,10 @@ fn default_commit_parsers() -> Vec<CommitParser> {
|
|||||||
default_scope: None,
|
default_scope: None,
|
||||||
scope: None,
|
scope: None,
|
||||||
skip: None,
|
skip: None,
|
||||||
|
field: None,
|
||||||
|
pattern: None,
|
||||||
|
sha: None,
|
||||||
|
footer: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +193,7 @@ fn default_commit_parsers() -> Vec<CommitParser> {
|
|||||||
create_commit_parser("removed", "removed"),
|
create_commit_parser("removed", "removed"),
|
||||||
create_commit_parser("fix", "fixed"),
|
create_commit_parser("fix", "fixed"),
|
||||||
create_commit_parser("security", "security"),
|
create_commit_parser("security", "security"),
|
||||||
|
create_commit_parser("docs", "docs"),
|
||||||
CommitParser {
|
CommitParser {
|
||||||
message: Regex::new(".*").ok(),
|
message: Regex::new(".*").ok(),
|
||||||
group: Some(String::from("other")),
|
group: Some(String::from("other")),
|
||||||
@ -190,6 +201,10 @@ fn default_commit_parsers() -> Vec<CommitParser> {
|
|||||||
default_scope: None,
|
default_scope: None,
|
||||||
skip: None,
|
skip: None,
|
||||||
scope: None,
|
scope: None,
|
||||||
|
field: None,
|
||||||
|
pattern: None,
|
||||||
|
sha: None,
|
||||||
|
footer: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -209,6 +224,7 @@ fn default_changelog_config(header: Option<String>, release_link: Option<&str>)
|
|||||||
body: Some(default_changelog_body_config(release_link)),
|
body: Some(default_changelog_body_config(release_link)),
|
||||||
footer: None,
|
footer: None,
|
||||||
trim: Some(true),
|
trim: Some(true),
|
||||||
|
postprocessors: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ pub enum VcsClient {
|
|||||||
source: PathBuf,
|
source: PathBuf,
|
||||||
username: String,
|
username: String,
|
||||||
email: String,
|
email: String,
|
||||||
|
token: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ impl VcsClient {
|
|||||||
path: &Path,
|
path: &Path,
|
||||||
git_username: Option<impl Into<String>>,
|
git_username: Option<impl Into<String>>,
|
||||||
git_email: Option<impl Into<String>>,
|
git_email: Option<impl Into<String>>,
|
||||||
|
git_token: String,
|
||||||
) -> anyhow::Result<VcsClient> {
|
) -> anyhow::Result<VcsClient> {
|
||||||
if !path.to_path_buf().join(".git").exists() {
|
if !path.to_path_buf().join(".git").exists() {
|
||||||
anyhow::bail!("git directory not found in: {}", path.display().to_string())
|
anyhow::bail!("git directory not found in: {}", path.display().to_string())
|
||||||
@ -32,6 +34,7 @@ impl VcsClient {
|
|||||||
email: git_email
|
email: git_email
|
||||||
.map(|e| e.into())
|
.map(|e| e.into())
|
||||||
.unwrap_or("bot@cuddle.sh".to_string()),
|
.unwrap_or("bot@cuddle.sh".to_string()),
|
||||||
|
token: git_token,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,10 +59,15 @@ impl VcsClient {
|
|||||||
source,
|
source,
|
||||||
username,
|
username,
|
||||||
email,
|
email,
|
||||||
|
token,
|
||||||
} => {
|
} => {
|
||||||
let checkout_branch = std::process::Command::new("git")
|
let checkout_branch = std::process::Command::new("git")
|
||||||
.current_dir(source.as_path())
|
.current_dir(source.as_path())
|
||||||
.args(&[
|
.args([
|
||||||
|
"-c",
|
||||||
|
&format!("http.extraHeader='Authorization: token {}'", token),
|
||||||
|
"-c",
|
||||||
|
"http.extraHeader='Sudo: kjuulh'",
|
||||||
"-c",
|
"-c",
|
||||||
&format!("user.name={}", username),
|
&format!("user.name={}", username),
|
||||||
"-c",
|
"-c",
|
||||||
@ -71,6 +79,13 @@ impl VcsClient {
|
|||||||
let stdout = std::str::from_utf8(&checkout_branch.stdout)?;
|
let stdout = std::str::from_utf8(&checkout_branch.stdout)?;
|
||||||
let stderr = std::str::from_utf8(&checkout_branch.stderr)?;
|
let stderr = std::str::from_utf8(&checkout_branch.stderr)?;
|
||||||
tracing::debug!(stdout = stdout, stderr = stderr, "git {}", args.join(" "));
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ impl RemoteGitEngine for GiteaClient {
|
|||||||
base: base.into(),
|
base: base.into(),
|
||||||
body: body.into(),
|
body: body.into(),
|
||||||
head: "cuddle-please/release".into(),
|
head: "cuddle-please/release".into(),
|
||||||
title: format!("chore(release): {}", version),
|
title: format!("chore(release): v{}", version),
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
@ -377,7 +377,7 @@ impl RemoteGitEngine for GiteaClient {
|
|||||||
|
|
||||||
let request = CreatePullRequestOption {
|
let request = CreatePullRequestOption {
|
||||||
body: body.into(),
|
body: body.into(),
|
||||||
title: format!("chore(release): {}", version),
|
title: format!("chore(release): v{}", version),
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
@ -429,9 +429,9 @@ impl RemoteGitEngine for GiteaClient {
|
|||||||
let request = CreateReleaseOption {
|
let request = CreateReleaseOption {
|
||||||
body: body.into(),
|
body: body.into(),
|
||||||
draft: false,
|
draft: false,
|
||||||
name: version.into(),
|
name: format!("v{version}"),
|
||||||
prerelease,
|
prerelease,
|
||||||
tag_name: version.into(),
|
tag_name: format!("v{version}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
@ -517,6 +517,7 @@ impl TryFrom<Tag> for Version {
|
|||||||
tracing::trace!(name = &value.name, "parsing tag into version");
|
tracing::trace!(name = &value.name, "parsing tag into version");
|
||||||
value
|
value
|
||||||
.name
|
.name
|
||||||
|
.trim_start_matches("v")
|
||||||
.parse::<Version>()
|
.parse::<Version>()
|
||||||
.context("could not get version from tag")
|
.context("could not get version from tag")
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ mod local_git_client;
|
|||||||
mod ui;
|
mod ui;
|
||||||
mod versioning;
|
mod versioning;
|
||||||
|
|
||||||
pub use args::{GlobalArgs, RemoteEngine, StdinFn};
|
pub use args::{GlobalArgs, LogLevel, RemoteEngine, StdinFn};
|
||||||
pub use cliff::{changelog_parser, ChangeLogBuilder};
|
pub use cliff::{changelog_parser, ChangeLogBuilder};
|
||||||
pub use git_client::VcsClient;
|
pub use git_client::VcsClient;
|
||||||
pub use gitea_client::{Commit, DynRemoteGitClient, GiteaClient, RemoteGitEngine, Tag};
|
pub use gitea_client::{Commit, DynRemoteGitClient, GiteaClient, RemoteGitEngine, Tag};
|
||||||
|
31
crates/cuddle-please-release-strategy/Cargo.toml
Normal file
31
crates/cuddle-please-release-strategy/Cargo.toml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[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"
|
||||||
|
]
|
60
crates/cuddle-please-release-strategy/src/json_edit.rs
Normal file
60
crates/cuddle-please-release-strategy/src/json_edit.rs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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(())
|
||||||
|
}
|
||||||
|
}
|
6
crates/cuddle-please-release-strategy/src/lib.rs
Normal file
6
crates/cuddle-please-release-strategy/src/lib.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#[cfg(feature = "json-edit")]
|
||||||
|
mod json_edit;
|
||||||
|
mod strategy;
|
||||||
|
|
||||||
|
#[cfg(feature = "json-edit")]
|
||||||
|
pub use json_edit::JsonEditOptions;
|
59
crates/cuddle-please-release-strategy/src/strategy.rs
Normal file
59
crates/cuddle-please-release-strategy/src/strategy.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
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(())
|
||||||
|
}
|
||||||
|
}
|
50
crates/cuddle-please-release-strategy/tests/json_edit.rs
Normal file
50
crates/cuddle-please-release-strategy/tests/json_edit.rs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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);
|
||||||
|
}
|
@ -1,7 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cuddle-please"
|
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"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
publishable = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuddle-please-frontend.workspace = true
|
cuddle-please-frontend.workspace = true
|
||||||
|
@ -2,7 +2,6 @@ use cuddle_please_commands::PleaseCommand;
|
|||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
tracing_subscriber::fmt::init();
|
|
||||||
|
|
||||||
let current_dir = std::env::current_dir().ok();
|
let current_dir = std::env::current_dir().ok();
|
||||||
let current_dir = current_dir.as_deref();
|
let current_dir = current_dir.as_deref();
|
||||||
|
@ -13,6 +13,7 @@ fn get_base_args<'a>() -> Vec<&'a str> {
|
|||||||
"list",
|
"list",
|
||||||
"--no-vcs",
|
"--no-vcs",
|
||||||
"--engine=local",
|
"--engine=local",
|
||||||
|
"--token=something",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +25,6 @@ PleaseConfig
|
|||||||
api_url: https://some-example.gitea-instance
|
api_url: https://some-example.gitea-instance
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[traced_test]
|
#[traced_test]
|
||||||
fn test_config_from_current_dir() {
|
fn test_config_from_current_dir() {
|
||||||
let args = get_base_args();
|
let args = get_base_args();
|
||||||
@ -38,7 +38,6 @@ fn test_config_from_current_dir() {
|
|||||||
assert_output(ui, EXPECTED_OUTPUT, "");
|
assert_output(ui, EXPECTED_OUTPUT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[traced_test]
|
#[traced_test]
|
||||||
fn test_config_from_source_dir() {
|
fn test_config_from_source_dir() {
|
||||||
let mut args = get_base_args();
|
let mut args = get_base_args();
|
||||||
@ -54,7 +53,6 @@ fn test_config_from_source_dir() {
|
|||||||
assert_output(ui, EXPECTED_OUTPUT, "");
|
assert_output(ui, EXPECTED_OUTPUT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[traced_test]
|
#[traced_test]
|
||||||
fn test_config_from_stdin() {
|
fn test_config_from_stdin() {
|
||||||
let mut args = get_base_args();
|
let mut args = get_base_args();
|
||||||
@ -74,7 +72,6 @@ settings:
|
|||||||
assert_output(ui, EXPECTED_OUTPUT, "");
|
assert_output(ui, EXPECTED_OUTPUT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[traced_test]
|
#[traced_test]
|
||||||
fn test_config_fails_when_not_path_is_set() {
|
fn test_config_fails_when_not_path_is_set() {
|
||||||
let args = get_base_args();
|
let args = get_base_args();
|
||||||
|
@ -17,7 +17,8 @@ fn exec_git_into_branch() {
|
|||||||
add_commit(tempdir.path(), "second").unwrap();
|
add_commit(tempdir.path(), "second").unwrap();
|
||||||
add_tag(tempdir.path(), "1.0.1").unwrap();
|
add_tag(tempdir.path(), "1.0.1").unwrap();
|
||||||
|
|
||||||
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
|
let vcs =
|
||||||
|
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
|
||||||
vcs.checkout_branch().unwrap();
|
vcs.checkout_branch().unwrap();
|
||||||
|
|
||||||
let output = std::process::Command::new("git")
|
let output = std::process::Command::new("git")
|
||||||
@ -48,7 +49,8 @@ fn add_files_to_commit() {
|
|||||||
add_commit(tempdir.path(), "first").unwrap();
|
add_commit(tempdir.path(), "first").unwrap();
|
||||||
add_tag(tempdir.path(), "1.0.0").unwrap();
|
add_tag(tempdir.path(), "1.0.0").unwrap();
|
||||||
|
|
||||||
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
|
let vcs =
|
||||||
|
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
|
||||||
vcs.checkout_branch().unwrap();
|
vcs.checkout_branch().unwrap();
|
||||||
|
|
||||||
std::fs::File::create(tempdir.path().join("changelog")).unwrap();
|
std::fs::File::create(tempdir.path().join("changelog")).unwrap();
|
||||||
@ -76,7 +78,8 @@ fn reset_branch() {
|
|||||||
add_commit(tempdir.path(), "first").unwrap();
|
add_commit(tempdir.path(), "first").unwrap();
|
||||||
add_tag(tempdir.path(), "1.0.0").unwrap();
|
add_tag(tempdir.path(), "1.0.0").unwrap();
|
||||||
|
|
||||||
let vcs = VcsClient::new_git(tempdir.path(), None::<String>, None::<String>).unwrap();
|
let vcs =
|
||||||
|
VcsClient::new_git(tempdir.path(), None::<String>, None::<String>, "".into()).unwrap();
|
||||||
vcs.checkout_branch().unwrap();
|
vcs.checkout_branch().unwrap();
|
||||||
|
|
||||||
std::fs::File::create(tempdir.path().join("changelog-first")).unwrap();
|
std::fs::File::create(tempdir.path().join("changelog-first")).unwrap();
|
||||||
@ -165,6 +168,12 @@ fn setup_git(path: &Path) -> anyhow::Result<()> {
|
|||||||
let stderr = std::str::from_utf8(&output.stderr)?;
|
let stderr = std::str::from_utf8(&output.stderr)?;
|
||||||
tracing::debug!(stdout = stdout, stderr = stderr, "git init");
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,23 @@ fn test_vcs_get_noop() {
|
|||||||
#[traced_test]
|
#[traced_test]
|
||||||
fn test_vcs_get_git_found() {
|
fn test_vcs_get_git_found() {
|
||||||
let testdata = get_test_data_path("git-found");
|
let testdata = get_test_data_path("git-found");
|
||||||
let git = VcsClient::new_git(&testdata, None::<String>, None::<String>).unwrap();
|
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();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
git,
|
git,
|
||||||
VcsClient::Git {
|
VcsClient::Git {
|
||||||
source: testdata,
|
source: testdata,
|
||||||
username: "cuddle-please".into(),
|
username: "cuddle-please".into(),
|
||||||
email: "bot@cuddle.sh".into()
|
email: "bot@cuddle.sh".into(),
|
||||||
|
token: "".into(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
26
cuddle.yaml
26
cuddle.yaml
@ -5,7 +5,9 @@ base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
|
|||||||
vars:
|
vars:
|
||||||
service: "cuddle-please"
|
service: "cuddle-please"
|
||||||
registry: kasperhermansen
|
registry: kasperhermansen
|
||||||
|
|
||||||
mkdocs_image: "squidfunk/mkdocs-material:9.1"
|
mkdocs_image: "squidfunk/mkdocs-material:9.1"
|
||||||
|
caddy_image: "caddy:2.7"
|
||||||
|
|
||||||
please:
|
please:
|
||||||
project:
|
project:
|
||||||
@ -14,10 +16,34 @@ please:
|
|||||||
branch: main
|
branch: main
|
||||||
settings:
|
settings:
|
||||||
api_url: https://git.front.kjuulh.io
|
api_url: https://git.front.kjuulh.io
|
||||||
|
actions:
|
||||||
|
rust:
|
||||||
|
|
||||||
|
components:
|
||||||
|
packages:
|
||||||
|
debian:
|
||||||
|
dev:
|
||||||
|
- jq
|
||||||
|
- git
|
||||||
|
release:
|
||||||
|
- jq
|
||||||
|
- git
|
||||||
|
|
||||||
scripts:
|
scripts:
|
||||||
"mkdocs:new":
|
"mkdocs:new":
|
||||||
type: shell
|
type: shell
|
||||||
"mkdocs:dev":
|
"mkdocs:dev":
|
||||||
type: shell
|
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
|
||||||
|
|
81
docs/configuration.md
Normal file
81
docs/configuration.md
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
156
docs/getting-started.md
Normal file
156
docs/getting-started.md
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
# 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.
|
@ -1,17 +1,35 @@
|
|||||||
# Welcome to MkDocs
|
# Cuddle docs
|
||||||
|
|
||||||
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
|
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`.
|
||||||
|
|
||||||
## Commands
|
The goal of the software is to be a `release-please` clone, targeting `gitea` instead of `github`.
|
||||||
|
|
||||||
* `mkdocs new [dir-name]` - Create a new project.
|
The tool can be executed as a binary using:
|
||||||
* `mkdocs serve` - Start the live-reloading docs server.
|
|
||||||
* `mkdocs build` - Build the documentation site.
|
|
||||||
* `mkdocs -h` - Print help message and exit.
|
|
||||||
|
|
||||||
## Project layout
|
```bash
|
||||||
|
cuddle please release # if using cuddle
|
||||||
|
# or
|
||||||
|
cuddle-please release # if using standalone
|
||||||
|
```
|
||||||
|
|
||||||
mkdocs.yml # The configuration file.
|
And when a release has been built:
|
||||||
docs/
|
|
||||||
index.md # The documentation homepage.
|
```bash
|
||||||
... # Other markdown pages, images and other files.
|
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
|
||||||
|
29
docs/installation.md
Normal file
29
docs/installation.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# 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
|
||||||
|
```
|
@ -19,3 +19,7 @@ theme:
|
|||||||
toggle:
|
toggle:
|
||||||
icon: material/brightness-4
|
icon: material/brightness-4
|
||||||
name: Switch to light mode # Palette toggle for light mode
|
name: Switch to light mode # Palette toggle for light mode
|
||||||
|
markdown_extensions:
|
||||||
|
- admonition
|
||||||
|
- pymdownx.details
|
||||||
|
- pymdownx.superfences
|
17
scripts/ci:main.sh
Executable file
17
scripts/ci:main.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/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"
|
15
scripts/ci:pr.sh
Executable file
15
scripts/ci:pr.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/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"
|
17
scripts/ci:release.sh
Executable file
17
scripts/ci:release.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/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"
|
5
scripts/local:docker.sh
Executable file
5
scripts/local:docker.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cargo run -p ci -- local docker-image --image kasperhermansen/cuddle-please --tag dev --bin-name cuddle-please
|
5
scripts/local:docker:docs.sh
Executable file
5
scripts/local:docker:docs.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cargo run -p ci -- local build-docs --mkdocs-image $MKDOCS_IMAGE --caddy-image $CADDY_IMAGE
|
5
scripts/mkdocs:build.sh
Executable file
5
scripts/mkdocs:build.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs ${MKDOCS_IMAGE}
|
1
scripts/publish:docker:docs.sh
Normal file
1
scripts/publish:docker:docs.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
8
templates/Caddyfile
Normal file
8
templates/Caddyfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
debug
|
||||||
|
}
|
||||||
|
|
||||||
|
http://blog.kasperhermansen.com {
|
||||||
|
root * /usr/share/caddy
|
||||||
|
file_server
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user