summaryrefslogtreecommitdiffstats
path: root/xtask
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2024-01-20 12:47:21 +0000
committerGitHub <noreply@github.com>2024-01-20 12:47:21 +0000
commit592cabeda8be80948e277887979696c815991ffc (patch)
tree6585d18e654554f51822a5e6189ee0a3f65fef69 /xtask
parented8ca9383e0530d6b6d54d6b778046690e6d826d (diff)
xtask: Disable pusing during publish (#3040)
* xtask: Add `--no-push` flag to `publish` which can be used when simulating releases to work without a writable git fork of the zellij code. * xtask: Fix borrow issues * xtask/pipe: Require lockfile in publish to avoid errors from invalid dependency versions. * CHANGELOG: Add PR #3040.
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/flags.rs3
-rw-r--r--xtask/src/pipelines.rs10
2 files changed, 11 insertions, 2 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index dd076f539..1c6936260 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -38,6 +38,8 @@ xflags::xflags! {
cmd publish {
/// Perform a dry-run (don't push/publish anything)
optional --dry-run
+ /// Publish but don't push a commit to git (only works with '--cargo-registry')
+ optional --no-push
/// Push commit to custom git remote
optional --git-remote remote: OsString
/// Publish crates to custom registry
@@ -159,6 +161,7 @@ pub struct Manpage;
#[derive(Debug)]
pub struct Publish {
pub dry_run: bool,
+ pub no_push: bool,
pub git_remote: Option<OsString>,
pub cargo_registry: Option<OsString>,
}
diff --git a/xtask/src/pipelines.rs b/xtask/src/pipelines.rs
index 4195af763..437cefbf2 100644
--- a/xtask/src/pipelines.rs
+++ b/xtask/src/pipelines.rs
@@ -197,10 +197,11 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
None
};
let remote = flags.git_remote.unwrap_or("origin".into());
- let registry = if let Some(registry) = flags.cargo_registry {
+ let registry = if let Some(ref registry) = flags.cargo_registry {
Some(format!(
"--registry={}",
registry
+ .clone()
.into_string()
.map_err(|registry| anyhow::Error::msg(format!(
"failed to convert '{:?}' to valid registry name",
@@ -212,6 +213,9 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
None
};
let registry = registry.as_ref();
+ if flags.no_push && flags.cargo_registry.is_none() {
+ anyhow::bail!("flag '--no-push' can only be used with '--cargo-registry'");
+ }
sh.change_dir(crate::project_root());
let cargo = crate::cargo().context(err_context)?;
@@ -304,6 +308,8 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
// Push commit and tag
if flags.dry_run {
println!("Skipping push due to dry-run");
+ } else if flags.no_push {
+ println!("Skipping push due to no-push");
} else {
cmd!(sh, "git push --atomic {remote} main v{version}")
.run()
@@ -331,7 +337,7 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
if let Err(err) = cmd!(
sh,
- "{cargo} publish {registry...} {more_args...} {dry_run...}"
+ "{cargo} publish --locked {registry...} {more_args...} {dry_run...}"
)
.run()
.context(err_context)