This commit is contained in:
Michael Zhang 2018-09-30 10:02:52 -05:00
parent 39d643a0cf
commit 3ea34f72e9
No known key found for this signature in database
GPG key ID: A1B65B603268116B
5 changed files with 55 additions and 77 deletions

View file

@ -1,11 +0,0 @@
pipeline:
build:
image: rust:1.25.0
commands:
- apt-get update -y && apt-get install -y libgtk-3-dev
- cargo check
- cargo build --release
cache:
mount:
- target

View file

@ -1,12 +1,32 @@
language: rust
sudo: required
sudo: false
cache: cargo
dist: trusty
script:
- if [ -z "$TRAVIS_TAG" ]; then ./ci/run.sh check leanshot; fi
addons:
apt:
packages:
- libx11-dev
- libimlib2-dev
- build-essential
- mesa-common-dev
before_deploy:
- ./ci/run.sh build leanshot ${TRAVIS_TAG}-${TRAVIS_OS_NAME}
env:
global:
- PROJECT_NAME=leanshot
matrix:
include:
- os: linux
rust: stable
env: TARGET=x86_64-unknown-linux-gnu
fast_finish: true
before_script: rustup target add $TARGET || echo ok
script:
- if [ -z "$TRAVIS_TAG" ]; then cargo check --all --target $TARGET; fi
before_deploy: ./ci/package $TRAVIS_TAG $TARGET
deploy:
- provider: releases

View file

@ -1,18 +0,0 @@
FROM ekidd/rust-musl-builder
RUN sudo apt-get update -y && sudo apt-get install -y\
libgl1-mesa-dri \
libglu1-mesa-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libx11-dev \
libimlib2-dev
ENV CFLAGS="-I /usr/include -I /usr/include/x86_64-linux-gnu -O3"
# Install nanovg
COPY . ./
USER root
ENV CARGO_HOME=/home/rust/.cargo
ENV RUSTUP_HOME=/home/rust/.multirust

30
ci/package Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
tag=$1
target=$2
if [[ -z "$tag" ]]; then
echo Tag is needed
exit 1
fi
if [[ -z "$target" ]]; then
echo Target is needed
exit 1
fi
cargo build --target $target --release
project="leanshot"
build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
name="$project-$tag-$target"
mkdir "$build_dir/$name"
cp target/$target/release/$project "$build_dir/$name/"
cp LICENSE "$build_dir/$name/"
pushd $build_dir
strip "$name/$project"
tar cvf "$out_dir/$name.tar" "$name"
popd
xz -f9 "$name.tar"

View file

@ -1,43 +0,0 @@
#!/bin/bash
#
# Modified version of build-release.sh
# Original comments left below.
#
# Usage: ./build-release <PROJECT> ${TRAVIS_TAG}-${TRAVIS_OS_NAME}
#
# The latest version of this script is available at
# https://github.com/emk/rust-musl-builder/blob/master/examples/build-release
#
# Called by `.travis.yml` to build release binaries. We use
# ekidd/rust-musl-builder to make the Linux binaries so that we can run
# them unchanged on any distro, including tiny distros like Alpine (which
# is heavily used for Docker containers). Other platforms get regular
# binaries, which will generally be dynamically linked against libc.
#
# If you have a platform which supports static linking of libc, and this
# would be generally useful, please feel free to submit patches.
set -euo pipefail
VOLUMES="-v $2-target:/home/rust/src/target -v $2-registry:/home/rust/.cargo/registry -v $2-git:/home/rust/.cargo/git"
case $1 in
check)
echo "Checking using rust-musl-builder"
docker build -f Dockerfile -t build-"$2"-image .
docker rm -f build-"$2" || true
docker run -it --name build-"$2" $VOLUMES build-"$2"-image bash -c 'cargo check -v --all'
docker rm build-"$2"
docker rmi build-"$2"-image
;;
build)
echo "Building static binaries using rust-musl-builder"
docker build -t build-"$2"-image .
docker rm -f build-"$2" || true
docker run -it --name build-"$2" $VOLUMES build-"$2"-image bash -c 'cargo build --release -v --all'
docker cp build-"$2":/home/rust/src/target/x86_64-unknown-linux-musl/release/"$2" "$2"
docker rm build-"$2"
docker rmi build-"$2"-image
tar czvf "$2"-"$3".tar.gz "$2"
;;
esac