2019-03-03 15:55:55 +00:00
|
|
|
# GitLab CI configuration for ffsend builds, tests and releases
|
|
|
|
#
|
|
|
|
# To add a new release:
|
|
|
|
# - configure a new 'build-*' job with the proper target
|
|
|
|
# - export a build artifact from the new job
|
|
|
|
# - manually upload artifact to GitHub in the 'github-release' job
|
|
|
|
|
2018-06-04 23:06:12 +00:00
|
|
|
image: "rust:slim"
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- check
|
2018-06-23 15:02:02 +00:00
|
|
|
- build
|
2018-06-04 23:06:12 +00:00
|
|
|
- test
|
|
|
|
- release
|
2019-03-03 19:32:10 +00:00
|
|
|
- package
|
2018-06-04 23:06:12 +00:00
|
|
|
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: stable
|
|
|
|
|
2018-11-20 15:23:32 +00:00
|
|
|
# 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/
|
|
|
|
|
2018-06-04 23:06:12 +00:00
|
|
|
# Install compiler and OpenSSL dependencies
|
|
|
|
before_script:
|
2018-06-23 15:02:02 +00:00
|
|
|
- apt-get update
|
2018-06-04 23:06:12 +00:00
|
|
|
- apt-get install -y --no-install-recommends build-essential pkg-config libssl-dev
|
2018-06-23 15:02:02 +00:00
|
|
|
- |
|
|
|
|
rustup install $RUST_VERSION
|
|
|
|
rustup default $RUST_VERSION
|
|
|
|
- |
|
|
|
|
rustc --version
|
|
|
|
cargo --version
|
2018-06-04 23:06:12 +00:00
|
|
|
|
2018-06-18 17:20:55 +00:00
|
|
|
# Variable defaults
|
|
|
|
variables:
|
|
|
|
RUST_VERSION: stable
|
2019-03-03 14:46:11 +00:00
|
|
|
RUST_TARGET: x86_64-unknown-linux-gnu
|
2018-06-18 17:20:55 +00:00
|
|
|
|
2019-03-03 23:21:15 +00:00
|
|
|
# Check on stable, beta and nightly
|
|
|
|
.check-base: &check-base
|
|
|
|
stage: check
|
|
|
|
script:
|
|
|
|
- cargo check --verbose
|
|
|
|
- cargo check --no-default-features --features send2 --verbose
|
|
|
|
- cargo check --no-default-features --features send3 --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.32.0"
|
2018-06-23 15:02:02 +00:00
|
|
|
|
|
|
|
# Build using Rust stable
|
2019-03-03 14:46:11 +00:00
|
|
|
build-x86_64-linux-gnu:
|
2018-06-23 15:02:02 +00:00
|
|
|
stage: build
|
|
|
|
script:
|
2019-03-03 14:46:11 +00:00
|
|
|
- cargo build --target=$RUST_TARGET --release --verbose
|
2019-03-03 15:24:00 +00:00
|
|
|
- mv target/$RUST_TARGET/release/ffsend ./ffsend-$RUST_TARGET
|
2019-03-03 15:55:55 +00:00
|
|
|
- strip -g ./ffsend-$RUST_TARGET
|
2018-06-23 15:02:02 +00:00
|
|
|
artifacts:
|
2019-03-03 14:46:11 +00:00
|
|
|
name: ffsend-x86_64-linux-gnu
|
2018-06-23 15:02:02 +00:00
|
|
|
paths:
|
2019-03-03 15:24:00 +00:00
|
|
|
- ffsend-$RUST_TARGET
|
2018-06-23 15:02:02 +00:00
|
|
|
expire_in: 1 month
|
|
|
|
|
|
|
|
# Build a static version
|
2019-03-03 14:46:11 +00:00
|
|
|
build-x86_64-linux-musl:
|
2018-06-23 15:02:02 +00:00
|
|
|
stage: build
|
2019-03-03 14:46:11 +00:00
|
|
|
variables:
|
|
|
|
RUST_TARGET: x86_64-unknown-linux-musl
|
2018-06-23 15:02:02 +00:00
|
|
|
script:
|
|
|
|
# Install the static target
|
2019-03-03 14:46:11 +00:00
|
|
|
- rustup target add $RUST_TARGET
|
2018-06-23 15:02:02 +00:00
|
|
|
|
|
|
|
# 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
|
2019-03-03 14:46:11 +00:00
|
|
|
- cargo build --target=$RUST_TARGET --release --verbose
|
2018-06-23 15:02:02 +00:00
|
|
|
|
2019-03-03 15:55:55 +00:00
|
|
|
# Prepare the release artifact, strip it
|
2018-06-23 15:02:02 +00:00
|
|
|
- find . -name ffsend -exec ls -lah {} \;
|
2019-03-03 15:24:00 +00:00
|
|
|
- mv target/$RUST_TARGET/release/ffsend ./ffsend-$RUST_TARGET
|
2019-03-03 15:55:55 +00:00
|
|
|
- strip -g ./ffsend-$RUST_TARGET
|
2018-06-23 15:02:02 +00:00
|
|
|
artifacts:
|
2019-03-03 14:46:11 +00:00
|
|
|
name: ffsend-x86_64-linux-musl
|
2018-06-23 15:02:02 +00:00
|
|
|
paths:
|
2019-03-03 15:24:00 +00:00
|
|
|
- ffsend-$RUST_TARGET
|
2018-06-23 15:02:02 +00:00
|
|
|
expire_in: 1 month
|
2018-06-04 23:06:12 +00:00
|
|
|
|
2019-03-03 23:21:15 +00:00
|
|
|
# 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
|
|
|
|
allow_failure: true
|
|
|
|
dependencies:
|
|
|
|
- build-x86_64-linux-musl
|
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none
|
|
|
|
RUST_TARGET: x86_64-unknown-linux-musl
|
|
|
|
before_script: []
|
|
|
|
script:
|
|
|
|
# Generate random file, upload/download and assert equality
|
|
|
|
- "head -c2m </dev/urandom >testfile"
|
|
|
|
- "./ffsend-$RUST_TARGET upload testfile -d=10 -p=secret -I"
|
|
|
|
- "./ffsend-$RUST_TARGET download $(./ffsend-$RUST_TARGET history -q) -p=secret -I -o=downloadfile"
|
|
|
|
- "./ffsend-$RUST_TARGET delete $(./ffsend-$RUST_TARGET history -q)"
|
|
|
|
- "cmp --silent ./testfile ./downloadfile || (echo ERROR: Downloaded file is different than original; exit 1)"
|
|
|
|
|
|
|
|
# Also test Firefox Send v3
|
|
|
|
- "./ffsend-$RUST_TARGET upload --host http://send2.dev.lcip.org/ testfile -d=10 -p=secret -I"
|
|
|
|
- "./ffsend-$RUST_TARGET download $(./ffsend-$RUST_TARGET history -q) -p=secret -I -o=downloadfile2"
|
|
|
|
- "./ffsend-$RUST_TARGET delete $(./ffsend-$RUST_TARGET history -q)"
|
|
|
|
- "cmp --silent ./testfile ./downloadfile2 || (echo ERROR: Downloaded file is different than original; exit 1)"
|
2019-02-28 08:56:50 +00:00
|
|
|
|
2018-10-17 15:48:37 +00:00
|
|
|
# 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..."
|
2018-10-17 18:26:25 +00:00
|
|
|
- cargo publish --verbose --allow-dirty
|
2019-01-03 13:08:50 +00:00
|
|
|
|
2019-03-06 15:43:21 +00:00
|
|
|
# Snap release
|
|
|
|
snap:
|
|
|
|
image: snapcore/snapcraft:edge
|
|
|
|
stage: release
|
|
|
|
only:
|
|
|
|
- /^v(\d+\.)*\d+$/
|
|
|
|
before_script: []
|
|
|
|
script:
|
|
|
|
# Prepare the environment
|
|
|
|
- apt-get update -y
|
|
|
|
- cd pkg/snap
|
|
|
|
|
2019-03-06 17:43:02 +00:00
|
|
|
# Update version number in snapcraft.yaml
|
2019-03-06 15:43:21 +00:00
|
|
|
- VERSION=$(echo $CI_COMMIT_REF_NAME | cut -c 2-)
|
2019-03-06 17:43:02 +00:00
|
|
|
- echo "Determined binary version number 'v$VERSION', updating snapcraft.yaml..."
|
|
|
|
- 'sed "s/^version:.*\$/version: $VERSION/" -i snapcraft.yaml'
|
|
|
|
- 'sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i snapcraft.yaml'
|
2019-03-06 15:43:21 +00:00
|
|
|
|
|
|
|
# Build the package
|
|
|
|
- echo "Building snap package..."
|
|
|
|
- snapcraft
|
|
|
|
|
|
|
|
# Publish snap package
|
|
|
|
- echo "Publishing snap package..."
|
|
|
|
- echo "$SNAP_MAIL\n&SNAP_PASSWORD" | snapcraft login
|
|
|
|
- snapcraft push --release=stable ffsend_*_amd64.snap
|
|
|
|
|
2019-03-03 15:24:00 +00:00
|
|
|
# Publish release binaries to as GitHub release
|
|
|
|
github-release:
|
|
|
|
stage: release
|
2019-03-03 23:21:15 +00:00
|
|
|
only:
|
|
|
|
- /^v(\d+\.)*\d+$/
|
2019-03-03 15:24:00 +00:00
|
|
|
dependencies:
|
|
|
|
- build-x86_64-linux-gnu
|
|
|
|
- build-x86_64-linux-musl
|
|
|
|
before_script: []
|
|
|
|
script:
|
2019-03-03 17:49:37 +00:00
|
|
|
# Install dependencies
|
|
|
|
- apt-get update
|
2019-03-03 23:53:03 +00:00
|
|
|
- apt-get install -y curl wget gzip netbase
|
2019-03-03 17:49:37 +00:00
|
|
|
|
2019-03-03 15:24:00 +00:00
|
|
|
# Download github-release binary
|
2019-03-03 19:32:10 +00:00
|
|
|
- wget $(curl -s https://api.github.com/repos/tfausak/github-release/releases/latest | grep 'browser_' | cut -d\" -f4 | grep 'linux') -O github-release.gz
|
|
|
|
- gunzip github-release.gz
|
2019-03-03 22:32:18 +00:00
|
|
|
- chmod a+x ./github-release
|
2019-03-03 15:24:00 +00:00
|
|
|
|
2019-03-03 23:20:12 +00:00
|
|
|
# Create the release, upload binaries
|
|
|
|
- ./github-release release --token "$GITHUB_TOKEN" --owner timvisee --repo ffsend --tag "$CI_COMMIT_REF_NAME" --title "ffsend $CI_COMMIT_REF_NAME"
|
|
|
|
- ./github-release upload --token "$GITHUB_TOKEN" --owner timvisee --repo ffsend --tag "$CI_COMMIT_REF_NAME" --file ./ffsend-x86_64-unknown-linux-gnu --name ffsend-$CI_COMMIT_REF_NAME-linux-x64
|
|
|
|
- ./github-release upload --token "$GITHUB_TOKEN" --owner timvisee --repo ffsend --tag "$CI_COMMIT_REF_NAME" --file ./ffsend-x86_64-unknown-linux-musl --name ffsend-$CI_COMMIT_REF_NAME-linux-x64-static
|
2019-03-03 15:24:00 +00:00
|
|
|
|
2019-03-03 17:31:21 +00:00
|
|
|
# AUR packages release
|
2019-03-03 19:32:10 +00:00
|
|
|
package-aur:
|
2019-02-28 20:00:03 +00:00
|
|
|
image: archlinux/base
|
2019-03-03 19:32:10 +00:00
|
|
|
stage: package
|
2019-01-12 22:19:11 +00:00
|
|
|
only:
|
|
|
|
- /^v(\d+\.)*\d+$/
|
|
|
|
before_script: []
|
|
|
|
script:
|
|
|
|
- cd ./pkg/aur
|
|
|
|
|
2019-03-03 17:49:37 +00:00
|
|
|
# Update version number in PKGBUILD
|
2019-01-12 22:19:11 +00:00
|
|
|
- VERSION=$(echo $CI_COMMIT_REF_NAME | cut -c 2-)
|
2019-03-03 17:31:21 +00:00
|
|
|
- echo "Determined binary version number 'v$VERSION', updating PKGBUILDs..."
|
|
|
|
- sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i bin/PKGBUILD
|
|
|
|
- sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i git/PKGBUILD
|
2019-01-12 22:19:11 +00:00
|
|
|
|
2019-03-03 17:49:37 +00:00
|
|
|
# Install dependencies
|
2019-01-12 22:19:11 +00:00
|
|
|
- echo "Installing required build packages..."
|
|
|
|
- pacman -Syu --noconfirm sudo base-devel binutils openssh rust cargo cmake git openssl
|
|
|
|
|
2019-03-03 17:49:37 +00:00
|
|
|
# Make AUR package
|
2019-01-12 22:19:11 +00:00
|
|
|
- echo "Making AUR package..."
|
|
|
|
- mkdir -p /.cargo
|
|
|
|
- chmod -R 777 /.cargo
|
2019-03-03 17:31:21 +00:00
|
|
|
- cd bin/
|
|
|
|
- echo "Making binary package..."
|
2019-01-12 22:19:11 +00:00
|
|
|
- sudo -u nobody makepkg -c
|
|
|
|
- sudo -u nobody makepkg --printsrcinfo > .SRCINFO
|
2019-03-03 17:31:21 +00:00
|
|
|
- cd ../git
|
|
|
|
- echo "Making git source package..."
|
|
|
|
- sudo -u nobody makepkg -c
|
|
|
|
- sudo -u nobody makepkg --printsrcinfo > .SRCINFO
|
|
|
|
- cd ..
|
2019-01-12 22:19:11 +00:00
|
|
|
|
2019-03-03 17:31:21 +00:00
|
|
|
# Set up SSH for publishing
|
2019-01-12 22:19:11 +00:00
|
|
|
- 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"
|
2019-03-03 17:31:21 +00:00
|
|
|
- git config --global user.email "tim@visee.me"
|
|
|
|
|
|
|
|
# Publish binary package: clone AUR repo, commit update and push
|
|
|
|
- git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend-bin
|
|
|
|
- cd aur-ffsend-bin
|
|
|
|
- cp ../bin/{PKGBUILD,.SRCINFO} ./
|
2019-01-12 22:19:11 +00:00
|
|
|
- git add PKGBUILD .SRCINFO
|
|
|
|
- git commit -m "Release v$VERSION"
|
|
|
|
- git push
|
2019-03-03 17:31:21 +00:00
|
|
|
- cd ..
|
|
|
|
|
|
|
|
# Publish git package: clone AUR repo, commit update and push
|
|
|
|
- git clone ssh://aur@aur.archlinux.org/ffsend-git.git aur-ffsend-git
|
|
|
|
- cd aur-ffsend-git
|
|
|
|
- cp ../git/{PKGBUILD,.SRCINFO} ./
|
|
|
|
- git add PKGBUILD .SRCINFO
|
|
|
|
- git commit -m "Release v$VERSION"
|
|
|
|
- git push
|
|
|
|
- cd ..
|
2019-01-20 16:37:52 +00:00
|
|
|
|
2019-03-05 06:59:54 +00:00
|
|
|
# # Trigger a release build on AppVeyor, for a Windows binary
|
|
|
|
# trigger-appveyor-release:
|
|
|
|
# stage: package
|
|
|
|
# only:
|
|
|
|
# - "/^v([0-9]+\\.)*[0-9]+.*$/"
|
|
|
|
# script:
|
|
|
|
# - apt-get install -y --no-install-recommends curl
|
|
|
|
# - export VERSION=$(echo $CI_COMMIT_REF_NAME | cut -c 2-)
|
|
|
|
# - 'curl -L -H "Content-Type: application/json" -H "Authorization: Bearer $APPVEYOR_TOKEN" -d "{\"accountName\":\"timvisee\",\"projectSlug\":\"ffsend\",\"tag\":\"$CI_COMMIT_REF_NAME\",\"environmentVariables\":{\"FFSEND_VERSION\":\"$VERSION\"}}" https://ci.appveyor.com/api/builds'
|
2019-03-04 19:38:27 +00:00
|
|
|
|
2019-03-03 17:31:21 +00:00
|
|
|
# TODO: add job to test ffsend{-git} AUR packages
|