fix(cli): automatic signing for iOS on CI (#10851)

ref https://github.com/tauri-apps/cargo-mobile2/pull/381
This commit is contained in:
Lucas Fernandes Nogueira 2024-08-31 17:58:58 -03:00 committed by GitHub
parent 5ec74456b9
commit 5af1f5dec1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 8 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---
Fixes `ios build` failing to build iOS app in CI when using an API key for automatic signing.

4
Cargo.lock generated
View File

@ -747,9 +747,9 @@ dependencies = [
[[package]]
name = "cargo-mobile2"
version = "0.15.1"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b8132519bea2d46174e777bd36d480d93afbe1df31c27cacfb411ff152bba1"
checksum = "e188b5be2e86ea9c384075d5f5560edea7b0c8b6a06553c7ab0aa61a4475f623"
dependencies = [
"colored",
"core-foundation 0.10.0",

View File

@ -36,7 +36,7 @@ name = "cargo-tauri"
path = "src/main.rs"
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
cargo-mobile2 = { version = "0.15.1", default-features = false }
cargo-mobile2 = { version = "0.16", default-features = false }
[dependencies]
jsonrpsee = { version = "0.24", features = ["server"] }

View File

@ -24,7 +24,7 @@ use anyhow::Context;
use cargo_mobile2::{
apple::{
config::Config as AppleConfig,
target::{ExportConfig, Target},
target::{BuildConfig, ExportConfig, Target},
},
env::Env,
opts::{NoiseLevel, Profile},
@ -299,11 +299,25 @@ fn run_build(
app_version.push_extra(build_number);
}
target.build(config, env, NoiseLevel::FranklyQuitePedantic, profile)?;
let credentials = auth_credentials_from_env()?;
let mut build_config = BuildConfig::new().allow_provisioning_updates();
if let Some(credentials) = &credentials {
build_config = build_config.authentication_credentials(credentials.clone());
}
target.build(
config,
env,
NoiseLevel::FranklyQuitePedantic,
profile,
build_config,
)?;
target.archive(config, env, noise_level, profile, Some(app_version))?;
let mut export_config = ExportConfig::new().allow_provisioning_updates();
if let Some(credentials) = auth_credentials_from_env()? {
if let Some(credentials) = credentials {
export_config = export_config.authentication_credentials(credentials);
}
@ -327,14 +341,14 @@ fn run_build(
Ok(handle)
}
fn auth_credentials_from_env() -> Result<Option<cargo_mobile2::apple::target::AuthCredentials>> {
fn auth_credentials_from_env() -> Result<Option<cargo_mobile2::apple::AuthCredentials>> {
match (
var("APPLE_API_KEY"),
var("APPLE_API_ISSUER"),
var_os("APPLE_API_KEY_PATH").map(PathBuf::from),
) {
(Ok(key_id), Ok(key_issuer_id), Some(key_path)) => {
Ok(Some(cargo_mobile2::apple::target::AuthCredentials {
Ok(Some(cargo_mobile2::apple::AuthCredentials {
key_path,
key_id,
key_issuer_id,