From bc063c3f471f1e75df230aaf5cd0c9e84a4b7a2a Mon Sep 17 00:00:00 2001 From: Xuesong Peng Date: Thu, 21 Mar 2024 11:03:13 +0800 Subject: [PATCH] resolve #1467: build sswinservice for Windows by default --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/build-msrv.yml | 2 +- .github/workflows/build-nightly-release.yml | 2 +- .github/workflows/build-release.yml | 6 +++++- build/build-host-release | 4 ++++ build/build-host-release.ps1 | 3 +++ 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 915be57857fc..047218289e08 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,6 +42,6 @@ jobs: run: cargo build --verbose --features "local-http-rustls local-redir local-dns local-tun dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" - name: Build with All Features Enabled (Windows) if: ${{ runner.os == 'Windows' }} - run: cargo build --verbose --features "local-http-rustls local-dns dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" + run: cargo build --verbose --features "local-http-rustls local-dns dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect winservice" - name: Build with All Features Enabled - shadowsocks run: cargo build --manifest-path ./crates/shadowsocks/Cargo.toml --verbose --features "stream-cipher aead-cipher-2022" diff --git a/.github/workflows/build-msrv.yml b/.github/workflows/build-msrv.yml index cbe8b6d6ed61..6bea06a43da4 100644 --- a/.github/workflows/build-msrv.yml +++ b/.github/workflows/build-msrv.yml @@ -34,4 +34,4 @@ jobs: run: cargo build --verbose --features "local-http-rustls local-redir local-dns local-tun dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" - name: Build with All Features Enabled (Windows) if: ${{ runner.os == 'Windows' }} - run: cargo build --verbose --features "local-http-rustls local-dns dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" + run: cargo build --verbose --features "local-http-rustls local-dns dns-over-tls dns-over-https stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect winservice" diff --git a/.github/workflows/build-nightly-release.yml b/.github/workflows/build-nightly-release.yml index 26b34b89c928..5d02827bfd35 100644 --- a/.github/workflows/build-nightly-release.yml +++ b/.github/workflows/build-nightly-release.yml @@ -116,7 +116,7 @@ jobs: - name: Build release run: | - pwsh ./build/build-host-release.ps1 + pwsh ./build/build-host-release.ps1 winservice - name: Upload Artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 061e616b399c..6b5ca2cd0c86 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -58,6 +58,10 @@ jobs: compile_features="-f local-redir -f local-tun" fi + if [[ "$compile_target" == *"-windows-"* ]]; then + compile_features="-f winservice" + fi + if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then sudo apt-get update -y && sudo apt-get install -y upx; if [[ "$?" == "0" ]]; then @@ -139,7 +143,7 @@ jobs: - name: Build release run: | - pwsh ./build/build-host-release.ps1 + pwsh ./build/build-host-release.ps1 winservice - name: Upload Github Assets uses: softprops/action-gh-release@v1 diff --git a/build/build-host-release b/build/build-host-release index 98eb20bad0e1..34580f510ba2 100755 --- a/build/build-host-release +++ b/build/build-host-release @@ -53,6 +53,10 @@ fi TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}") +if [[ "${BUILD_FEATURES}" == *"winservice"* ]]; then + TARGETS+=("sswinservice${TARGET_SUFFIX}") +fi + RELEASE_FOLDER="${ROOT_DIR}/release" RELEASE_PACKAGE_NAME="shadowsocks-v${VERSION}.${BUILD_TARGET}" diff --git a/build/build-host-release.ps1 b/build/build-host-release.ps1 index f539f55d3fbf..3fb9e7eadfdc 100644 --- a/build/build-host-release.ps1 +++ b/build/build-host-release.ps1 @@ -48,6 +48,9 @@ $CompressParam = @{ LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe", "ssservice.exe" DestinationPath = "${PackagePath}" } +if (${Features} -contains "winservice") { + $CompressParam.LiteralPath += "sswinservice.exe" +} Compress-Archive @CompressParam Write-Host "Created release packet ${PackagePath}"