diff --git a/.circleci/config.yml b/.circleci/config.yml index 32bde1de..2fdf0464 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,15 +16,15 @@ jobs: steps: - checkout - - run: | - sudo apt-get update - sudo apt-get install -y build-essential - - run: | - rustc --version >rust-version - test -e Cargo.lock || cargo generate-lockfile + - run: + name: "APT install dependencies" + command: | + sudo apt-get update + sudo apt-get install -y build-essential - restore_cache: key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }} - run: + name: "Build release" command: BUILD_EXTRA_FEATURES="openssl-vendored local-redir" ./build-host-release no_output_timeout: 1h - save_cache: @@ -35,6 +35,10 @@ jobs: - store_artifacts: path: ./build/release destination: releases + - persist_to_workspace: + root: /tmp/workspace + paths: + - build/release build-windows: executor: windows/default @@ -47,74 +51,74 @@ jobs: steps: - checkout - - run: | - $ProgressPreference = "SilentlyContinue" - Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\rustup-init.exe" - & C:\rustup-init.exe -y --default-toolchain "stable-x86_64-pc-windows-msvc" --no-modify-path --profile minimal + - run: + name: "Install Rust" + command: | + $ProgressPreference = "SilentlyContinue" + Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\rustup-init.exe" + & C:\rustup-init.exe -y --default-toolchain "stable-x86_64-pc-windows-msvc" --no-modify-path --profile minimal - $env:Path += ";C:\Users\circleci\.cargo\bin" - rustc -Vv - cargo --version - - run: | - $env:Path += ";C:\Users\circleci\.cargo\bin" + $env:Path += ";C:\Users\circleci\.cargo\bin" + rustc -Vv + cargo --version + - run: + name: "Install OpenSSL" + command: | + $env:Path += ";C:\Users\circleci\.cargo\bin" - $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1] - if ($TargetTriple.StartsWith("x86_64-")) { - $OpenSSLBits = "64" - } else { - $OpenSSLBits = "32" - } - $OpenSSLVersion = "1_1_0L" - $OpenSSLFileName = "Win${OpenSSLBits}OpenSSL-${OpenSSLVersion}.exe" + $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1] + if ($TargetTriple.StartsWith("x86_64-")) { + $OpenSSLBits = "64" + } else { + $OpenSSLBits = "32" + } + $OpenSSLVersion = "1_1_0L" + $OpenSSLFileName = "Win${OpenSSLBits}OpenSSL-${OpenSSLVersion}.exe" - $ProgressPreference = "SilentlyContinue" - Invoke-WebRequest -Uri "http://slproweb.com/download/${OpenSSLFileName}" -OutFile "${OpenSSLFileName}" - Write-Host "* Done downloading ${OpenSSLFileName}" - dir - Start-Process "${OpenSSLFileName}" -ArgumentList "/SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /DIR=C:\OpenSSL" -Wait - Write-Host "* Done installing ${OpenSSLFileName}" - - run: | - $env:Path += ";C:\Users\circleci\.cargo\bin" - - rustc --version | Out-File -FilePath "rust-version" - if (!(Test-Path "Cargo.lock" -PathType Leaf)) { - cargo generate-lockfile - } + $ProgressPreference = "SilentlyContinue" + Invoke-WebRequest -Uri "http://slproweb.com/download/${OpenSSLFileName}" -OutFile "${OpenSSLFileName}" + Write-Host "* Done downloading ${OpenSSLFileName}" + dir + Start-Process "${OpenSSLFileName}" -ArgumentList "/SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /DIR=C:\OpenSSL" -Wait + Write-Host "* Done installing ${OpenSSLFileName}" - restore_cache: key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }} # - run: ./build-host-release - run: + name: "Build release" command: | $env:Path += ";C:\Users\circleci\.cargo\bin" cargo build --release --features "aes-pmac-siv" no_output_timeout: 1h - - run: | - $ProgressPreference = "SilentlyContinue" - $env:Path += ";C:\Users\circleci\.cargo\bin;." + - run: + name: "Package release" + command: | + $ProgressPreference = "SilentlyContinue" + $env:Path += ";C:\Users\circleci\.cargo\bin;." - $PackageReleasePath = "${PWD}\build\release" + $PackageReleasePath = "${PWD}\build\release" - Pushd target\release - $Version = (sslocal -V).split()[-1] - $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1] - $PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip" - $PackagePath = "${PackageReleasePath}\${PackageName}" + Pushd target\release + $Version = (sslocal -V).split()[-1] + $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1] + $PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip" + $PackagePath = "${PackageReleasePath}\${PackageName}" - Write-Host "${Version}" - Write-Host "${TargetTriple}" - Write-Host "${PackagePath}" + Write-Host "${Version}" + Write-Host "${TargetTriple}" + Write-Host "${PackagePath}" - New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue - $CompressParam = @{ - LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe" - DestinationPath = "${PackagePath}" - } - Compress-Archive @CompressParam - Popd + New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue + $CompressParam = @{ + LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe" + DestinationPath = "${PackagePath}" + } + Compress-Archive @CompressParam + Popd - $PackageChecksumPath = "${PackagePath}.sha256" - $PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash - "${PackageHash} ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}" + $PackageChecksumPath = "${PackagePath}.sha256" + $PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash + "${PackageHash} ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}" - save_cache: paths: - C:\Users\circleci\.cargo\registry @@ -123,6 +127,10 @@ jobs: - store_artifacts: path: build\\release destination: releases + - persist_to_workspace: + root: /tmp/workspace + paths: + - build\\release build-docker: machine: @@ -131,28 +139,35 @@ jobs: steps: - checkout - - run: | - sudo apt-get update - sudo apt-get install curl - - run: | - cd build - docker build -t shadowsocks-rust:x86_64-pc-windows-gnu -f Dockerfile.x86_64-pc-windows-gnu . - docker build -t shadowsocks-rust:x86_64-unknown-linux-musl -f Dockerfile.x86_64-unknown-linux-musl . - docker build -t shadowsocks-rust:arm-unknown-linux-gnueabihf -f Dockerfile.arm-unknown-linux-gnueabihf . - docker build -t shadowsocks-rust:aarch64-unknown-linux-gnu -f Dockerfile.aarch64-unknown-linux-gnu . - - run: | - curl "https://sh.rustup.rs" -o "rust-init.sh" - chmod +x "rust-init.sh" - ./rust-init.sh -y --default-toolchain stable --no-modify-path --profile minimal - export PATH="$HOME/.cargo/bin:$PATH" - echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> $BASH_ENV - rustup --version - cargo --version - rustc --version + - run: + name: "APT install dependencies" + command: | + sudo apt-get update + sudo apt-get install curl + - run: + name: "Build docker images" + command: | + cd build + docker build -t shadowsocks-rust:x86_64-pc-windows-gnu -f Dockerfile.x86_64-pc-windows-gnu . + docker build -t shadowsocks-rust:x86_64-unknown-linux-musl -f Dockerfile.x86_64-unknown-linux-musl . + docker build -t shadowsocks-rust:arm-unknown-linux-gnueabihf -f Dockerfile.arm-unknown-linux-gnueabihf . + docker build -t shadowsocks-rust:aarch64-unknown-linux-gnu -f Dockerfile.aarch64-unknown-linux-gnu . + - run: + name: "Install Rust" + command: | + curl "https://sh.rustup.rs" -o "rust-init.sh" + chmod +x "rust-init.sh" + ./rust-init.sh -y --default-toolchain stable --no-modify-path --profile minimal + export PATH="$HOME/.cargo/bin:$PATH" + echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> $BASH_ENV + rustup --version + cargo --version + rustc --version - restore_cache: key: cargo-cache-{{ arch }} - run: cargo install cross - run: + name: "Build release" command: | cd build ./build-release @@ -165,7 +180,22 @@ jobs: - store_artifacts: path: ./build/release destination: releases + - persist_to_workspace: + root: /tmp/workspace + paths: + - build/release + publish-github-releases: + docker: + - image: circleci/rust:stretch + environment: + steps: + - attach_workspace: + at: /tmp/workspace + - run: + name: "Publish release on GitHub" + command: | + ghr -t "${GITHUB_TOKEN}" -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" -c "${CIRCLE_SHA1}" -replace "${CIRCLE_TAG}" ./build/release workflows: version: 2 build-releases: @@ -173,3 +203,12 @@ workflows: - build-linux - build-windows - build-docker + - publish-github-releases: + requires: + - build-linux + - build-windows + - build-docker + branches: + ignore: /.*/ + tags: + only: /^v\d+\.\d+\.\d+$/