ffsend/.gitlab-ci.yml
2019-01-12 22:19:11 +00:00

179 lines
4.7 KiB
YAML

image: "rust:slim"
stages:
- check
- build
- test
- release
variables:
RUST_VERSION: stable
# Cache rust/cargo/build artifacts
cache:
key: "$CI_PIPELINE_ID-$RUST_VERSION"
paths:
- /usr/local/cargo/registry/
- /usr/local/rustup/toolchains/
- /usr/local/rustup/update-hashes/
- target/
# Install compiler and OpenSSL dependencies
before_script:
- apt-get update
- apt-get install -y --no-install-recommends build-essential pkg-config libssl-dev
- |
rustup install $RUST_VERSION
rustup default $RUST_VERSION
- |
rustc --version
cargo --version
# Variable defaults
variables:
RUST_VERSION: stable
# Check on stable, beta and nightly
.check-base: &check-base
stage: check
script:
- cargo check --verbose
- cargo check --no-default-features --verbose
- cargo check --features no-color --verbose
rust-stable:
<<: *check-base
rust-beta:
<<: *check-base
variables:
RUST_VERSION: beta
rust-nightly:
<<: *check-base
variables:
RUST_VERSION: nightly
# rust-old:
# <<: *check-base
# variables:
# RUST_VERSION: "1.26"
# Build using Rust stable
build:
stage: build
script:
- cargo build --release --verbose
- mv target/release/ffsend ./ffsend
artifacts:
name: build-dynamic
paths:
- ffsend
expire_in: 1 month
# Build a static version
build-static:
stage: build
script:
# Install the static target
- rustup target add x86_64-unknown-linux-musl
# Build OpenSSL statically
- apt install -y build-essential wget musl-tools
- wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
- tar xzvf openssl-1.0.2o.tar.gz
- cd openssl-1.0.2o
- ./config -fPIC --openssldir=/usr/local/ssl --prefix=/usr/local
- make
- make install
- cd ..
# Statically build ffsend
- export OPENSSL_STATIC=1
- export OPENSSL_LIB_DIR=/usr/local/lib
- export OPENSSL_INCLUDE_DIR=/usr/local/include
- cargo build --target=x86_64-unknown-linux-musl --release --verbose
# Prepare the release artifact
- find . -name ffsend -exec ls -lah {} \;
- mv target/x86_64-unknown-linux-musl/release/ffsend ./ffsend
artifacts:
name: build-static
paths:
- ffsend
expire_in: 1 month
# Run the unit tests through Cargo
cargo-test:
stage: test
dependencies: []
script:
- cargo test --verbose
# Run integration test with the public Send service
public-send-test:
stage: test
dependencies:
- build-static
variables:
GIT_STRATEGY: none
before_script: []
script:
# Generate random file, upload/download and assert equality
- "head -c16m </dev/urandom >testfile"
- "./ffsend upload testfile -d=10 -p=secret -I"
- "./ffsend download $(./ffsend history -q) -p=secret -I -o=downloadfile"
- "cmp --silent ./testfile ./downloadfile || (echo ERROR: Downloaded file is different than original; exit 1)"
# Cargo crate release
crate:
stage: release
only:
- /^v(\d+\.)*\d+$/
script:
- echo "Creating release crate to publish on crates.io..."
- echo $CARGO_TOKEN | cargo login
- echo "Publishing crate to crates.io..."
- cargo publish --verbose --allow-dirty
# AUR package release
pkg-aur:
image: base/archlinux
stage: release
only:
- /^v(\d+\.)*\d+$/
before_script: []
script:
- cd ./pkg/aur
# Update version number in PKGBUILD
- VERSION=$(echo $CI_COMMIT_REF_NAME | cut -c 2-)
- echo "Determined binary version number 'v$VERSION', updating PKGBUILD..."
- sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i PKGBUILD
# Install dependencies
- echo "Installing required build packages..."
- pacman -Syu --noconfirm sudo base-devel binutils openssh rust cargo cmake git openssl
# Make AUR package
- echo "Making AUR package..."
- mkdir -p /.cargo
- chmod -R 777 /.cargo
- sudo -u nobody makepkg -c
- sudo -u nobody makepkg --printsrcinfo > .SRCINFO
# Publish: set up SSH key, clone AUR repo, commit update and push
- mkdir -p /root/.ssh
- cp ./aur.pub /root/.ssh/id_rsa.pub
- echo "$AUR_SSH_PRIVATE" > /root/.ssh/id_rsa
- echo "Host aur.archlinux.org" >> /root/.ssh/config
- echo " IdentityFile /root/.ssh/aur" >> /root/.ssh/config
- echo " User aur" >> /root/.ssh/config
- chmod 600 /root/.ssh/{id_rsa*,config}
- eval `ssh-agent -s`
- ssh-add /root/.ssh/id_rsa
- ssh-keyscan -H aur.archlinux.org >> /root/.ssh/known_hosts
- git config --global user.name "timvisee"
- git config --global user.email "timvisee@gmail.com"
- git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend
- cd aur-ffsend
- cp ../{PKGBUILD,.SRCINFO} ./
- git add PKGBUILD .SRCINFO
- git commit -m "Release v$VERSION"
- git push