Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtask: Disable pusing during publish #3040

Merged
merged 4 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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