Skip to content

Commit

Permalink
feat: skip password prompt on the build command if CI is set fixes #6089
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jan 19, 2023
1 parent 8fb1df8 commit d4f89af
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/empty-tauri-key-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Skip the password prompt on the build command when `TAURI_KEY_PASSWORD` environment variable is empty and the `--ci` argument is provided or the `CI` environment variable is set.
2 changes: 1 addition & 1 deletion examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ pub struct Options {
pub config: Option<String>,
/// Command line arguments passed to the runner
pub args: Vec<String>,
/// Skip prompting for values
#[clap(long)]
ci: bool,
}

pub fn command(mut options: Options) -> Result<()> {
options.ci = options.ci || std::env::var("CI").is_ok();
let ci = options.ci;

let (merge_config, merge_config_path) = if let Some(config) = &options.config {
if config.starts_with('{') {
(Some(config.to_string()), None)
Expand Down Expand Up @@ -271,7 +277,9 @@ pub fn command(mut options: Options) -> Result<()> {
// If updater is active and we bundled it
if config_.tauri.updater.active && !updater_bundles.is_empty() {
// if no password provided we use an empty string
let password = var_os("TAURI_KEY_PASSWORD").map(|v| v.to_str().unwrap().to_string());
let password = var_os("TAURI_KEY_PASSWORD")
.map(|v| v.to_str().unwrap().to_string())
.or_else(|| if ci { Some("".into()) } else { None });
// get the private key
let secret_key = if let Some(mut private_key) =
var_os("TAURI_PRIVATE_KEY").map(|v| v.to_str().unwrap().to_string())
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/signer/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Options {
#[clap(short, long)]
force: bool,
/// Skip prompting for values
#[clap(short, long)]
#[clap(long)]
ci: bool,
}

Expand Down

0 comments on commit d4f89af

Please sign in to comment.