From 0f82aa5950e3966b0c1ded6512841d7324a2ba18 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Fri, 6 May 2022 12:43:30 +0200 Subject: [PATCH] Create macOS release builds with bundled root certificates (#272) As reported in https://github.com/dbrgn/tealdeer/issues/244, some users on macOS had problems with `rustls-tls-native-roots`. Since we did not find the root cause of this, we'll build macOS release builds with `rustls-tls-webpki-roots` instead. Fixes #244. --- .github/workflows/ci.yml | 7 +++---- .github/workflows/release.yml | 2 +- Cargo.toml | 5 ++++- src/main.rs | 8 ++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fd0512..148913c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,16 +27,15 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - - name: Build with all features + - name: Build with logging and webpki roots uses: actions-rs/cargo@v1 with: command: build - args: --all-features + args: --features logging,webpki-roots --no-default-features - name: Run tests uses: actions-rs/cargo@v1 with: command: test - args: --all-features clippy: name: run clippy lints @@ -51,7 +50,7 @@ jobs: - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features + args: --features logging fmt: name: run rustfmt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb0c0cf..1e42acc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --release --target x86_64-apple-darwin + args: --release --target x86_64-apple-darwin --no-default-features --features webpki-roots - uses: actions/upload-artifact@v2 with: name: "tealdeer-macos-x86_64" diff --git a/Cargo.toml b/Cargo.toml index 6715a8e..842a9e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ atty = "0.2" clap = { version = "3", features = ["std", "derive", "suggestions", "color"], default-features = false } env_logger = { version = "0.9", optional = true } log = "0.4" -reqwest = { version = "0.11.3", features = ["blocking", "rustls-tls", "rustls-tls-native-roots"], default-features = false } +reqwest = { version = "0.11.3", features = ["blocking"], default-features = false } serde = "1.0.21" serde_derive = "1.0.21" toml = "0.5.1" @@ -44,6 +44,9 @@ tempfile = "3.1.0" filetime = "0.2.10" [features] +default = ["native-roots"] +native-roots = ["reqwest/rustls-tls-native-roots"] +webpki-roots = ["reqwest/rustls-tls-webpki-roots"] logging = ["env_logger"] [profile.release] diff --git a/src/main.rs b/src/main.rs index 216c349..8449565 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,14 @@ #![allow(clippy::struct_excessive_bools)] #![allow(clippy::too_many_lines)] +#[cfg(any( + all(feature = "native-roots", feature = "webpki-roots"), + not(any(feature = "native-roots", feature = "webpki-roots")), +))] +compile_error!( + "exactly one of feature \"native-roots\" and feature \"webpki-roots\" must be enabled" +); + use std::{env, process}; use app_dirs::AppInfo;