Skip to content

Commit

Permalink
fix!: Remove dev-version support
Browse files Browse the repository at this point in the history
This just adds enough complications to the workflow that I'm removing
it.  People can always do this manually if they want with `cargo release
version`.
  • Loading branch information
epage committed Oct 17, 2022
1 parent b4d959a commit 77009fd
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 159 deletions.
2 changes: 0 additions & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ Workspace configuration is read from the following (in precedence order)
| `tag-message` | \- | string | `"(cargo-release) {{crate_name}} version {{version}}"` | A message template for an annotated tag (set to blank for lightweight tags). The placeholder `{{tag_name}}` and `{{prefix}}` (the tag prefix) is supported in addition to the global placeholders mentioned below. |
| `tag-prefix` | `--tag-prefix` | string | *depends* | Prefix of git tag, note that this will override default prefix based on crate name. |
| `tag-name` | `--tag-name` | string | `"{{prefix}}v{{version}}"` | The name of the git tag. The placeholder `{{prefix}}` (the tag prefix) is supported in addition to the global placeholders mentioned below. |
| `dev-version-ext` | `--dev-version-ext` | string | `"alpha.0" ` | Pre-release extension to use on the next development version. |
| `dev-version` | `--no-dev-version` | bool | `false` | Disable version bump after release. |
| `pre-release-replacements` | \- | array of tables (see below) | `[]` | Specify files that cargo-release will search and replace with new version for the release commit |
| `post-release-replacements` | \- | array of tables (see below) | `[]` | Specify files that cargo-release will search and replace with new version for the post-release commit (the one starting development) |
| `pre-release-hook` | \- | list of arguments | \- | Provide a command to run before `cargo-release` commits version change. If the return code of hook command is greater than 0, the release process will be aborted. |
Expand Down
30 changes: 0 additions & 30 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub struct Config {
pub verify: Option<bool>,
pub push: Option<bool>,
pub push_options: Option<Vec<String>>,
pub dev_version_ext: Option<String>,
pub dev_version: Option<bool>,
pub shared_version: Option<bool>,
pub consolidate_commits: Option<bool>,
pub pre_release_commit_message: Option<String>,
Expand Down Expand Up @@ -69,8 +67,6 @@ impl Config {
.map(|s| s.to_owned())
.collect::<Vec<String>>(),
),
dev_version_ext: Some(empty.dev_version_ext().to_owned()),
dev_version: Some(empty.dev_version()),
shared_version: Some(empty.shared_version()),
consolidate_commits: Some(empty.consolidate_commits()),
pre_release_commit_message: Some(empty.pre_release_commit_message().to_owned()),
Expand Down Expand Up @@ -120,12 +116,6 @@ impl Config {
if let Some(push_options) = source.push_options.as_deref() {
self.push_options = Some(push_options.to_owned());
}
if let Some(dev_version_ext) = source.dev_version_ext.as_deref() {
self.dev_version_ext = Some(dev_version_ext.to_owned());
}
if let Some(dev_version) = source.dev_version {
self.dev_version = Some(dev_version);
}
if let Some(shared_version) = source.shared_version {
self.shared_version = Some(shared_version);
}
Expand Down Expand Up @@ -219,14 +209,6 @@ impl Config {
.flat_map(|v| v.iter().map(|s| s.as_str()))
}

pub fn dev_version_ext(&self) -> &str {
self.dev_version_ext.as_deref().unwrap_or("alpha.0")
}

pub fn dev_version(&self) -> bool {
self.dev_version.unwrap_or(false)
}

pub fn shared_version(&self) -> bool {
self.shared_version.unwrap_or(false)
}
Expand Down Expand Up @@ -507,16 +489,6 @@ pub struct ConfigArgs {
#[arg(long, value_enum)]
pub dependent_version: Option<crate::config::DependentVersion>,

/// Pre-release identifier(s) to append to the next development version after release
#[arg(long)]
pub dev_version_ext: Option<String>,

/// Create dev version after release
#[arg(long, overrides_with("no_dev_version"))]
pub dev_version: bool,
#[arg(long, overrides_with("dev_version"), hide(true))]
pub no_dev_version: bool,

/// Comma-separated globs of branch names a release can happen from
#[arg(long, value_delimiter = ',')]
pub allow_branch: Option<Vec<String>>,
Expand All @@ -538,8 +510,6 @@ impl ConfigArgs {
sign_commit: resolve_bool_arg(self.sign_commit, self.no_sign_commit)
.or_else(|| self.sign()),
sign_tag: self.sign(),
dev_version_ext: self.dev_version_ext.clone(),
dev_version: resolve_bool_arg(self.dev_version, self.no_dev_version),
dependent_version: self.dependent_version,
..Default::default()
};
Expand Down
16 changes: 0 additions & 16 deletions src/steps/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::ops::cargo;
use crate::ops::git;
use crate::ops::replace::Template;
use crate::ops::version;
use crate::ops::version::VersionExt as _;

pub fn load(
args: &config::ConfigArgs,
Expand Down Expand Up @@ -76,7 +75,6 @@ pub struct PackageRelease {

pub planned_version: Option<version::Version>,
pub planned_tag: Option<String>,
pub post_version: Option<version::Version>,
}

impl PackageRelease {
Expand Down Expand Up @@ -125,7 +123,6 @@ impl PackageRelease {

let planned_version = None;
let planned_tag = None;
let post_version = None;

let pkg = PackageRelease {
meta: pkg_meta.clone(),
Expand All @@ -145,7 +142,6 @@ impl PackageRelease {

planned_version,
planned_tag,
post_version,
};
Ok(Some(pkg))
}
Expand Down Expand Up @@ -210,19 +206,7 @@ impl PackageRelease {
None
};

let is_pre_release = base.is_prerelease();
let post_version = if !is_pre_release && self.config.dev_version() {
let mut post = base.full_version.clone();
post.increment_patch();
post.pre = semver::Prerelease::new(self.config.dev_version_ext())?;

Some(version::Version::from(post))
} else {
None
};

self.planned_tag = tag;
self.post_version = post_version;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/steps/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl PushStep {
// STEP 1: Release Confirmation
super::confirm("Push", &pkgs, self.no_confirm, dry_run)?;

// STEP 7: git push
// STEP 6: git push
push(&ws_config, &ws_meta, &pkgs, dry_run)?;

super::finish(failed, dry_run)
Expand Down
106 changes: 1 addition & 105 deletions src/steps/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,111 +374,7 @@ impl ReleaseStep {
// STEP 5: Tag
super::tag::tag(&pkgs, dry_run)?;

// STEP 6: bump version
let mut shared_commit = false;
let mut shared_post_version: Option<version::Version> = None;
for pkg in &pkgs {
if let Some(next_version) = pkg.post_version.as_ref() {
let cwd = &pkg.package_root;
let crate_name = pkg.meta.name.as_str();

log::info!(
"Starting {}'s next development iteration {}",
crate_name,
next_version.full_version_string
);
crate::steps::version::update_dependent_versions(pkg, next_version, dry_run)?;
cargo::set_package_version(
&pkg.manifest_path,
next_version.full_version_string.as_str(),
dry_run,
)?;
if !dry_run {
cargo::update_lock(&pkg.manifest_path)?;
}
let version = pkg.planned_version.as_ref().unwrap_or(&pkg.initial_version);
let prev_version_var = pkg.initial_version.bare_version_string.as_str();
let prev_metadata_var = pkg.initial_version.full_version.build.as_str();
let version_var = version.bare_version_string.as_str();
let metadata_var = version.full_version.build.as_str();
let next_version_var = next_version.bare_version_string.as_ref();
let next_metadata_var = next_version.full_version.build.as_ref();
let template = Template {
prev_version: Some(prev_version_var),
prev_metadata: Some(prev_metadata_var),
version: Some(version_var),
metadata: Some(metadata_var),
crate_name: Some(crate_name),
date: Some(NOW.as_str()),
tag_name: pkg.planned_tag.as_deref(),
next_version: Some(next_version_var),
next_metadata: Some(next_metadata_var),
..Default::default()
};
if !pkg.config.post_release_replacements().is_empty() {
// try replacing text in configured files
let noisy = false;
do_file_replacements(
pkg.config.post_release_replacements(),
&template,
cwd,
false, // post-release replacements should always be applied
noisy,
dry_run,
)?;
}

if pkg.config.shared_version() && shared_post_version.is_none() {
shared_post_version = Some(next_version.clone());
}
if pkg.config.consolidate_commits() {
shared_commit = true;
} else {
let sign = pkg.config.sign_commit();

let commit_msg = template.render(pkg.config.post_release_commit_message());
if !git::commit_all(cwd, &commit_msg, sign, dry_run)? {
return Err(101.into());
}
}
}
}
if shared_commit {
let shared_commit_msg = {
let version_var = shared_version
.as_ref()
.map(|v| v.bare_version_string.as_str());
let metadata_var = shared_version
.as_ref()
.map(|v| v.full_version.build.as_str());
let next_version_var = shared_post_version
.as_ref()
.map(|v| v.bare_version_string.as_str());
let next_metadata_var = shared_post_version
.as_ref()
.map(|v| v.full_version.build.as_str());
let template = Template {
version: version_var,
metadata: metadata_var,
date: Some(NOW.as_str()),
next_version: next_version_var,
next_metadata: next_metadata_var,
..Default::default()
};
template.render(ws_config.post_release_commit_message())
};
if !git::commit_all(
ws_meta.workspace_root.as_std_path(),
&shared_commit_msg,
ws_config.sign_commit(),
dry_run,
)? {
// commit failed, abort release
return Err(101.into());
}
}

// STEP 7: git push
// STEP 6: git push
super::push::push(&ws_config, &ws_meta, &pkgs, dry_run)?;

super::finish(failed, dry_run)
Expand Down
5 changes: 0 additions & 5 deletions src/steps/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ pub fn changed_since<'m>(
since_ref,
crate_name
);
} else if pkg.config.dev_version() {
log::debug!(
"Ignoring lock file change since {}; could be a pre-release version bump.",
since_ref
);
} else {
lock_changed = true;
}
Expand Down

0 comments on commit 77009fd

Please sign in to comment.