From 28ce861b10318cee2bb0b53f7c5cb818a6a1d6f2 Mon Sep 17 00:00:00 2001 From: spencerwooo Date: Mon, 27 Nov 2023 16:20:46 +0800 Subject: [PATCH] fix build release ci, use rustls in favor of openssl --- .github/workflows/release.yml | 134 +++++++++++++----- Cargo.lock | 253 +++++++++++----------------------- Cargo.toml | 7 +- 3 files changed, 179 insertions(+), 215 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2633fa2..28772ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,68 +4,128 @@ on: workflow_dispatch: push: tags: - - "*" + - 'v[0-9]+.[0-9]+.[0-9]+' + +permissions: + actions: read + contents: write jobs: build: - name: Build and publish release - runs-on: ubuntu-latest + name: Release for ${{ matrix.target }} + runs-on: ${{ matrix.os }} + + # Prevent job from running on forks + if: ${{ !github.event.repository.fork }} + strategy: fail-fast: false matrix: + target: + - x86_64-unknown-linux-gnu + - x86_64-unknown-linux-musl + - aarch64-unknown-linux-gnu + - aarch64-unknown-linux-musl + - x86_64-pc-windows-msvc + - i686-pc-windows-msvc + - x86_64-apple-darwin + - aarch64-apple-darwin + include: - target: x86_64-unknown-linux-gnu - name: bitsrun-x86_64-unknown-linux-gnu.tar.gz + os: ubuntu-22.04 + target-apt-arch: amd64 cross: false - strip: true - target: x86_64-unknown-linux-musl - name: bitsrun-x86_64-unknown-linux-musl.tar.gz - cross: true - strip: true - - target: i686-unknown-linux-gnu - name: bitsrun-i686-unknown-linux-gnu.tar.gz - cross: true - strip: true - - target: i686-unknown-linux-musl - name: bitsrun-i686-unknown-linux-musl.tar.gz - cross: true - strip: true + os: ubuntu-22.04 + target-apt-arch: amd64 + cross: false - target: aarch64-unknown-linux-gnu - name: bitsrun-aarch64-unknown-linux-gnu.tar.gz + os: ubuntu-22.04 + target-apt-arch: arm64 cross: true - strip: false - target: aarch64-unknown-linux-musl - name: bitsrun-aarch64-unknown-linux-musl.tar.gz + os: ubuntu-22.04 + target-apt-arch: arm64 cross: true - strip: false + - target: x86_64-pc-windows-msvc + os: windows-latest + cross: false + - target: i686-pc-windows-msvc + os: windows-latest + cross: false + - target: x86_64-apple-darwin + os: macos-latest + cross: false + - target: aarch64-apple-darwin + os: macos-latest + cross: false + + env: + BIN_NAME: bitsrun + CARGO_BUILD_TARGET: ${{ matrix.target }} + ARCHIVE_NAME: bitsrun-${{ matrix.target }} steps: - uses: actions/checkout@master - - uses: dtolnay/rust-toolchain@stable + + - name: Set up Ubuntu multiarch + if: startsWith(matrix.os, 'ubuntu') && matrix.target-apt-arch != 'amd64' + run: | + readonly DISTRO_CODENAME=jammy + sudo dpkg --add-architecture "${{ matrix.target-apt-arch }}" + sudo sed -i "s/^deb http/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] http/" /etc/apt/sources.list + sudo sed -i "s/^deb mirror/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] mirror/" /etc/apt/sources.list + for suite in '' '-updates' '-backports' '-security'; do + echo "deb [arch=${{ matrix.target-apt-arch }}] http://ports.ubuntu.com/ $DISTRO_CODENAME$suite main universe multiverse" | \ + sudo tee -a /etc/apt/sources.list >/dev/null + done + + - name: Install musl development files + if: endsWith(matrix.target, '-musl') + run: | + sudo apt-get -yq update + sudo apt-get -yq install musl-tools musl-dev:${{ matrix.target-apt-arch }} + + - name: Install QEMU and AArch64 cross compiler + if: startsWith(matrix.target, 'aarch64-unknown-linux') + run: | + sudo apt-get -yq update + # libc6 must be present to run executables dynamically linked + # against glibc for the target architecture + sudo apt-get -yq install qemu-user gcc-aarch64-linux-gnu libc6:arm64 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable with: - target: ${{ matrix.target }} + target: ${{ env.CARGO_BUILD_TARGET }} - name: Build binaries - uses: ClementTsang/cargo-action@v0.0.6 - with: - command: build - args: --release --target=${{ matrix.target }} - use-cross: ${{ matrix.cross }} + run: cargo build --release --target=${{ env.CARGO_BUILD_TARGET }} - - name: Strip binaries - run: strip target/${{ matrix.target }}/release/bitsrun - if: ${{ matrix.strip }} + - name: Strip binaries for Linux and macOS + if: endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') == false + run: strip target/${{ env.CARGO_BUILD_TARGET }}/release/${{ env.BIN_NAME }} + + - name: Package binary archives (for Windows) + if: endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') + run: | + New-Item -ItemType Directory -Force -Path ${{ env.ARCHIVE_NAME }} + Copy-Item -Path "target/${{ env.CARGO_BUILD_TARGET }}/release/${{ env.BIN_NAME }}.exe" -Destination "${{ env.ARCHIVE_NAME }}/" + Compress-Archive -Path "${{ env.ARCHIVE_NAME }}/*" -DestinationPath "${{ env.ARCHIVE_NAME }}.zip" - - name: Package binaries + - name: Package binary archives (for Linux and macOS) + if: endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') == false run: | - cd target/${{ matrix.target }}/release - tar -czvf ${{ matrix.name }} bitsrun - cd - + mkdir "${{ env.ARCHIVE_NAME }}" + cp target/${{ env.CARGO_BUILD_TARGET }}/release/${{ env.BIN_NAME }} "${{ env.ARCHIVE_NAME }}" + chmod ugo+x "${{ env.ARCHIVE_NAME }}/${{ env.BIN_NAME }}" + tar -vczf "${{ env.ARCHIVE_NAME }}.tar.gz" "${{ env.ARCHIVE_NAME }}"/*;; - - name: Upload binaries to release + - name: Upload binary for release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/${{ matrix.target }}/release/${{ matrix.name }} - asset_name: ${{ matrix.name }} + file: ${{ env.ARCHIVE_NAME }}${{ endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') && '.zip' || '.tar.gz'}} + asset_name: ${{env.ARCHIVE_NAME}}-${{ github.ref_name }}-${{ endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') && '.zip' || '.tar.gz'}} tag: ${{ github.ref }} diff --git a/Cargo.lock b/Cargo.lock index 89a7bea..b1fe2c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,43 +362,12 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "errno" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.0" @@ -588,16 +557,17 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "bytes", + "futures-util", + "http", "hyper", - "native-tls", + "rustls", "tokio", - "tokio-native-tls", + "tokio-rustls", ] [[package]] @@ -664,12 +634,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.150" @@ -693,12 +657,6 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" - [[package]] name = "lock_api" version = "0.4.11" @@ -763,24 +721,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nom" version = "7.1.3" @@ -825,50 +765,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "openssl" -version = "0.10.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" -dependencies = [ - "bitflags 2.4.1", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -935,12 +831,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1018,29 +908,45 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-tls", + "hyper-rustls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys", +] + [[package]] name = "rpassword" version = "7.3.1" @@ -1079,60 +985,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] -name = "rustix" -version = "0.38.24" +name = "rustls" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", + "log", + "ring", + "rustls-webpki", + "sct", ] [[package]] -name = "ryu" -version = "1.0.15" +name = "rustls-pemfile" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] [[package]] -name = "schannel" -version = "0.1.22" +name = "rustls-webpki" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "windows-sys", + "ring", + "untrusted", ] [[package]] -name = "scopeguard" -version = "1.2.0" +name = "ryu" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] -name = "security-framework" -version = "2.9.2" +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "security-framework-sys" -version = "2.9.1" +name = "sct" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "core-foundation-sys", - "libc", + "ring", + "untrusted", ] [[package]] @@ -1233,6 +1135,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "strsim" version = "0.10.0" @@ -1314,19 +1222,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -1393,12 +1288,12 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "native-tls", + "rustls", "tokio", ] @@ -1480,6 +1375,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -1497,12 +1398,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" @@ -1621,6 +1516,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index f0e34c2..eacf39f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.11", features = [ + "json", + "rustls-tls", # in favor of native openssl +], default-features = false } tokio = { version = "1", features = ["full"] } url = "2.4" serde_json = "1.0" @@ -22,7 +25,7 @@ directories = "5.0" owo-colors = "3" rpassword = "7.3" rprompt = "2.1" -tabled = { version ="0.14", features = ["color"]} +tabled = { version = "0.14", features = ["color"] } humansize = "2.1.3" chrono-humanize = "0.2.3" chrono = "0.4.31"