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.
This commit is contained in:
parent
ed8ca9383e
commit
592cabeda8
3 changed files with 12 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|||
* perf(plugins): improve plugin download & load feature (https://github.com/zellij-org/zellij/pull/3001)
|
||||
* chore: bump Rust toolchain to 1.75.0 (https://github.com/zellij-org/zellij/pull/3039)
|
||||
* feat(plugins): introduce pipes to control data flow to plugins from the command line (https://github.com/zellij-org/zellij/pull/3066)
|
||||
* feat(xtask): allow publishing without pushing changes (https://github.com/zellij-org/zellij/pull/3040)
|
||||
|
||||
## [0.39.2] - 2023-11-29
|
||||
* fix(cli): typo in cli help (https://github.com/zellij-org/zellij/pull/2906)
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue