diff --git a/CHANGELOG.md b/CHANGELOG.md index 382862931..ac8fb8cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)). @@ -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. \ No newline at end of file diff --git a/cli/src/lib.rs b/cli/src/lib.rs index ee2dbc791..0dfc86ffe 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -258,6 +258,10 @@ pub enum Command { last = true )] cargo_args: Vec, + /// 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 { @@ -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, @@ -2845,6 +2850,7 @@ fn publish( cfg_override: &ConfigOverride, program_name: String, cargo_args: Vec, + skip_build: bool, ) -> Result<()> { // Discover the various workspace configs. let cfg = Config::discover(cfg_override)?.expect("Not in workspace."); @@ -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)?;