Files
shadowsocks-rust/.circleci/config.yml
2020-02-06 13:53:37 +08:00

159 lines
6.2 KiB
YAML

version: 2.1
orbs:
windows: circleci/windows@2.4.0
jobs:
build-linux:
docker:
- image: circleci/rust:stretch
environment:
OPENSSL_STATIC: "1"
OPENSSL_LIB_DIR: "/usr/lib/x86_64-linux-gnu/"
OPENSSL_INCLUDE_DIR: "/usr/include/x86_64-linux-gnu/"
RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3"
steps:
- checkout
- run: |
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev
- run: |
rustc --version >rust-version
test -e Cargo.lock || cargo generate-lockfile
- restore_cache:
key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
- run: ./build-host-release
- save_cache:
paths:
- /usr/local/cargo/registry
- ./target
key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
- store_artifacts:
path: ./build/release
destination: releases
build-windows:
executor: windows/default
environment:
OPENSSL_STATIC: "1"
OPENSSL_DIR: "C:\\OpenSSL"
RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3"
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
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
$env:Path += ";C:\Users\circleci\.cargo\bin"
rustc -Vv
cargo --version
- run: |
$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_1d"
$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}"
dir C:\
dir ${env:OPENSSL_DIR}
dir "${env:OPENSSL_DIR}\lib"
- 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
}
- restore_cache:
key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
# - run: ./build-host-release
- run: |
$env:Path += ";C:\Users\circleci\.cargo\bin"
cargo build --release --features "miscreant"
- run: |
$env:Path += ";C:\Users\circleci\.cargo\bin"
$Version = (sslocal -V).split()[-1]
$TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1]
$PackageName = "shadowsocks-v$($Version)-stable.$($TargetTriple).zip"
$PackagePath = "$($pwd)\build\release\$($PackageName)"
Pushd target\release
$CompressParam = @{
LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "sstunnel.exe"
DestinationPath = "$($PackagePath)"
}
Compress-Archive @CompressParam
Popd
- save_cache:
paths:
- C:\Users\circleci\.cargo\registry
- target
key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
- store_artifacts:
path: build\\release
destination: releases
build-docker:
machine:
image: ubuntu-1604:201903-01
docker_layer_caching: true
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 .
- 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
- restore_cache:
key: cargo-cache-{{ arch }}
- run: cargo install cross
- run: |
cd build
./build-release
- save_cache:
paths:
- /usr/local/cargo/registry
- ./target
key: cargo-cache-{{ arch }}
- store_artifacts:
path: ./build/release
destination: releases
workflows:
version: 2
build-releases:
jobs:
- build-linux
- build-windows
- build-docker