From 3ea34f72e900548ef7340d0920ee648349c9da24 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 30 Sep 2018 10:02:52 -0500 Subject: [PATCH] a --- .drone.yml | 11 ----------- .travis.yml | 30 +++++++++++++++++++++++++----- Dockerfile | 18 ------------------ ci/package | 30 ++++++++++++++++++++++++++++++ ci/run.sh | 43 ------------------------------------------- 5 files changed, 55 insertions(+), 77 deletions(-) delete mode 100644 .drone.yml delete mode 100644 Dockerfile create mode 100755 ci/package delete mode 100755 ci/run.sh diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index fe4b367..0000000 --- a/.drone.yml +++ /dev/null @@ -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 diff --git a/.travis.yml b/.travis.yml index 4bb05bf..2407284 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 06946e3..0000000 --- a/Dockerfile +++ /dev/null @@ -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 diff --git a/ci/package b/ci/package new file mode 100755 index 0000000..5bab033 --- /dev/null +++ b/ci/package @@ -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" diff --git a/ci/run.sh b/ci/run.sh deleted file mode 100755 index f24aee9..0000000 --- a/ci/run.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# Modified version of build-release.sh -# Original comments left below. -# -# Usage: ./build-release ${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