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

cli/publish --skip-build flag #1841

Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

* cli: Add `--skip-build` to `anchor publish` ([#1786](https://github.
com/project-serum/anchor/pull/1841)).
* cli: Add `--program-keypair` to `anchor deploy` ([#1786](https://github.com/project-serum/anchor/pull/1786)).
* spl: Add more derived traits to `TokenAccount` to `Mint` ([#1818](https://github.com/project-serum/anchor/pull/1818)).
* cli: Add compilation optimizations to cli template ([#1807](https://github.com/project-serum/anchor/pull/1807)).
Expand Down Expand Up @@ -621,4 +623,4 @@ Initial release.
* spl: `anchor-spl` crate providing CPI clients for Anchor programs.
* client: `anchor-client` crate providing Rust clients for Anchor programs.
* ts: `@project-serum/anchor` package for generating TypeScript clients.
* cli: Command line interface for managing Anchor programs.
* cli: Command line interface for managing Anchor programs.
43 changes: 24 additions & 19 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ pub enum Command {
last = true
)]
cargo_args: Vec<String>,
/// Flag to skip building the program in the workspace,
/// use this to save time when publishing the program
#[clap(long)]
skip_build: bool,
},
/// Keypair commands.
Keys {
Expand Down Expand Up @@ -470,7 +474,8 @@ pub fn entry(opts: Opts) -> Result<()> {
Command::Publish {
program,
cargo_args,
} => publish(&opts.cfg_override, program, cargo_args),
skip_build,
} => publish(&opts.cfg_override, program, cargo_args, skip_build),
Command::Keys { subcmd } => keys(&opts.cfg_override, subcmd),
Command::Localnet {
skip_build,
Expand Down Expand Up @@ -2845,6 +2850,7 @@ fn publish(
cfg_override: &ConfigOverride,
program_name: String,
cargo_args: Vec<String>,
skip_build: bool,
) -> Result<()> {
// Discover the various workspace configs.
let cfg = Config::discover(cfg_override)?.expect("Not in workspace.");
Expand Down Expand Up @@ -2956,24 +2962,23 @@ fn publish(
unpack_archive(&tarball_filename)?;

// Build the program before sending it to the server.
build(
cfg_override,
None,
None,
true,
false,
Some(program_name),
None,
None,
BootstrapMode::None,
None,
None,
cargo_args,
true,
)?;

// Success. Now we can finally upload to the server without worrying
// about a build failure.
if !skip_build {
build(
cfg_override,
None,
None,
true,
false,
Some(program_name),
None,
None,
BootstrapMode::None,
None,
None,
cargo_args,
true,
)?;
}

// Upload the tarball to the server.
let token = registry_api_token(cfg_override)?;
Expand Down