diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 73e847c6..9caefd12 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,6 +8,7 @@ on: env: CARGO_TERM_COLOR: always + RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3" jobs: build-linux: diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f32153fc..96a327a3 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -37,20 +37,18 @@ jobs: build-unix: runs-on: ${{ matrix.os }} env: - BUILD_EXTRA_FEATURES: ${{ matrix.extra-features }} + BUILD_EXTRA_FEATURES: "openssl-vendored local-redir" RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3" strategy: matrix: - include: - - os: ubuntu-latest - extra-features: openssl-vendored local-redir - - os: macos-latest - extra-features: openssl-vendored local-redir + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v2 - name: Build release shell: bash - run: ./build-host-release + run: | + cd build + ./build-host-release - uses: actions/upload-artifact@v2 with: name: releases @@ -64,11 +62,10 @@ jobs: RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3" steps: - uses: actions/checkout@v2 - - name: setup (windows) - run: choco install openssl - name: Build release - shell: bash - run: ./build-host-release + run: | + cd build + pwsh build-host-release.ps1 - uses: actions/upload-artifact@v2 with: name: releases diff --git a/build-host-release b/build/build-host-release similarity index 84% rename from build-host-release rename to build/build-host-release index 30beea07..5d2b452a 100755 --- a/build-host-release +++ b/build/build-host-release @@ -13,9 +13,11 @@ while getopts "t:" opt; do done ROOT_DIR=$( cd $( dirname $0 ) && pwd ) -VERSION=$(grep -E '^version' "${ROOT_DIR}/Cargo.toml" | awk '{print $3}' | sed 's/"//g') +VERSION=$(grep -E '^version' "${ROOT_DIR}/../Cargo.toml" | awk '{print $3}' | sed 's/"//g') HOST_TRIPLE=$(rustc -Vv | grep 'host:' | awk '{print $2}') +echo "Started build release for ${HOST_TRIPLE} ..." + if [[ "${BUILD_TARGET}" != "" ]]; then cargo build --release --features "aes-pmac-siv ${BUILD_EXTRA_FEATURES}" --target "${BUILD_TARGET}" else @@ -33,16 +35,16 @@ fi TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}") -RELEASE_FOLDER="${ROOT_DIR}/build/release" +RELEASE_FOLDER="${ROOT_DIR}/release" RELEASE_PACKAGE_NAME="shadowsocks-v${VERSION}.${HOST_TRIPLE}" mkdir -p "${RELEASE_FOLDER}" # Into release folder if [[ "${BUILD_TARGET}" != "" ]]; then - cd "target/${BUILD_TARGET}/release" + cd "${ROOT_DIR}/../target/${BUILD_TARGET}/release" else - cd "target/release" + cd "${ROOT_DIR}/../target/release" fi if [[ "${HOST_TRIPLE}" == *"-windows-"* ]]; then @@ -66,3 +68,5 @@ else cd "${RELEASE_FOLDER}" shasum -a 256 "${RELEASE_PACKAGE_FILE_NAME}" > "${RELEASE_PACKAGE_FILE_NAME}.sha256" fi + +echo "Finished build release ${RELEASE_PACKAGE_FILE_PATH}" diff --git a/build/build-host-release.ps1 b/build/build-host-release.ps1 new file mode 100644 index 00000000..61a20d60 --- /dev/null +++ b/build/build-host-release.ps1 @@ -0,0 +1,43 @@ +<# + OpenSSL is already installed on windows-latest virtual environment. + If you need OpenSSL, consider install it by: + + choco install openssl +#> +$ErrorActionPreference = "Stop" + +$TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1] + +Write-Host "Started building release for ${TargetTriple} ..." + +cargo build --release --features "aes-pmac-siv openssl-vendored" + +$Version = (Select-String -Pattern '^version *= *"([^"]*)"$' -Path "${PSScriptRoot}\..\Cargo.toml" | foreach {$_.Matches.Value}).split()[-1] +$Version = $Version -replace '"' + +$PackageReleasePath = "${PSScriptRoot}\release" +$PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip" +$PackagePath = "${PackageReleasePath}\${PackageName}" + +Write-Host $Version +Write-Host $PackageReleasePath +Write-Host $PackageName +Write-Host $PackagePath + +Pushd "${PSScriptRoot}\..\target\release" + +$ProgressPreference = "SilentlyContinue" +New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue +$CompressParam = @{ + LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe" + DestinationPath = "${PackagePath}" +} +Compress-Archive @CompressParam + +Write-Host "Created release packet ${PackagePath}" + +$PackageChecksumPath = "${PackagePath}.sha256" +$PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash +"${PackageHash} ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}" + +Write-Host "Created release packet checksum ${PackageChecksumPath}"