mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
176 lines
7.2 KiB
YAML
176 lines
7.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
|
|
- 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:
|
|
command: BUILD_EXTRA_FEATURES="openssl-vendored local-redir" ./build-host-release
|
|
no_output_timeout: 1h
|
|
- 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_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
|
|
}
|
|
- restore_cache:
|
|
key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
|
|
# - run: ./build-host-release
|
|
- run:
|
|
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;."
|
|
|
|
$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}"
|
|
|
|
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
|
|
|
|
$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
|
|
- 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 .
|
|
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
|
|
- restore_cache:
|
|
key: cargo-cache-{{ arch }}
|
|
- run: cargo install cross
|
|
- run:
|
|
command: |
|
|
cd build
|
|
./build-release
|
|
no_output_timeout: 1h
|
|
- 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
|