Skip to content

Commit

Permalink
xtask: Disable pusing during publish (zellij-org#3040)
Browse files Browse the repository at this point in the history
* 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 zellij-org#3040.
  • Loading branch information
har7an authored and xuanyuan300 committed Jan 23, 2024
1 parent 6283a48 commit 69089dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions xtask/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>,
}
Expand Down
10 changes: 8 additions & 2 deletions xtask/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)?;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 69089dd

Please sign in to comment.