From a914f940ae38fb39b79ba832ce0d21082ca11d99 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 9 Sep 2018 21:27:44 -0500 Subject: [PATCH] travis builds --- .dockerignore | 2 ++ .travis.yml | 52 ++++++++++++++++++--------------------------- Cargo.toml | 2 +- Dockerfile | 14 ++++++++++++ ci/build-release.sh | 34 +++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 ci/build-release.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/.travis.yml b/.travis.yml index a3c4ec9..caf9d7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,16 @@ language: rust +sudo: required +cache: cargo + rust: -- stable -- nightly -os: -- linux + - stable + - nightly +os: linux matrix: fast_finish: true -sudo: true -dist: trusty -addons: - apt: - update: true - packages: - - cmake - - libgles2-mesa-dev - - libglew-dev - - libglfw3-dev - - libglm-dev - - libgtk-3-dev + +services: + - docker before_script: - git clone https://github.com/naelstrof/slop.git @@ -26,25 +19,22 @@ before_script: - make && sudo make install script: -- cargo build --all -- cargo test --all + - if [ -z "$TRAVIS_TAG" ]; then cargo test --all; fi before_deploy: -- cargo build --release --all -- mkdir -p release -- cp target/release/screenshot release -- cp LICENSE release -- tar czvf monto-rs-$(TARGET)-$(TRAVIS_TAG).tar.gz release + - ./ci/build-release.sh dip ${TRAVIS_TAG}-${TRAVIS_OS_NAME} deploy: - provider: releases - api_key: - secure: ZCA3+LjTzliSC3m9DjcEYZOsRhaI5r9LAHfuw5HuaLYbprbEVwqLCTV1ioe7F9dLPembqGoGEsVnWAsrAUP0C9BRUuOrZMYvTOS3qTwSX7pPc/fsNUzP9uc6XPIMQ7/QeakmpgVYvObt9/1Wxui715nPmj9h+YIB4P3BUT8VsufzG0LogNSTwkhicM19O9oFhoCg39qQBueBe2SrS35dqvofSoJlEk2wSBBesQ9xuw9goP8ZkTKD3w/ZmPUS9RuWi1FSzsUcnLGCEMwYxLk9CBnG9I0G8kvDF194UYq7YnlaK4sn4AG5UxkMYcWN573vb+KX56VoHa57Z7qNIoUy1Kk0MatIjPIxd2LQJSTl7I5sckfoq61wihRYYj8R1qI4V4mqBX+MHFwyfs7/XT2pVfPHeflvJ4MMZW5t+OYWv8LfwFgufbLyYS79ZkBIjVnk2ligSv8kSPcuTtnSzp6UJlHsEbRDlWcciAYA92d2bggz7BrSG+X1eDAVto+bGdAeAp5zgRPVKwbpA9aD52y2GmlMh4Z+GcjhF6U7z+2AYRalH9X8d4mSdQ7KuhFfigoR/84tO+kC5QeKnf3FfgXPzOimt8xCsd2MFDrg2sPvgFkQGyM0ihB9NnNBfiFrQrRP3+DyTCI3TqOfkz8QKe4h7DxefR1t+YvheNZjGtC8C+E= - file: screenshot-$(TARGET)-$(TRAVIS_TAG).tar.gz - on: - tags: true - repo: iptq/screenshot - skip_cleanup: true + - provider: releases + api_key: + secure: ZCA3+LjTzliSC3m9DjcEYZOsRhaI5r9LAHfuw5HuaLYbprbEVwqLCTV1ioe7F9dLPembqGoGEsVnWAsrAUP0C9BRUuOrZMYvTOS3qTwSX7pPc/fsNUzP9uc6XPIMQ7/QeakmpgVYvObt9/1Wxui715nPmj9h+YIB4P3BUT8VsufzG0LogNSTwkhicM19O9oFhoCg39qQBueBe2SrS35dqvofSoJlEk2wSBBesQ9xuw9goP8ZkTKD3w/ZmPUS9RuWi1FSzsUcnLGCEMwYxLk9CBnG9I0G8kvDF194UYq7YnlaK4sn4AG5UxkMYcWN573vb+KX56VoHa57Z7qNIoUy1Kk0MatIjPIxd2LQJSTl7I5sckfoq61wihRYYj8R1qI4V4mqBX+MHFwyfs7/XT2pVfPHeflvJ4MMZW5t+OYWv8LfwFgufbLyYS79ZkBIjVnk2ligSv8kSPcuTtnSzp6UJlHsEbRDlWcciAYA92d2bggz7BrSG+X1eDAVto+bGdAeAp5zgRPVKwbpA9aD52y2GmlMh4Z+GcjhF6U7z+2AYRalH9X8d4mSdQ7KuhFfigoR/84tO+kC5QeKnf3FfgXPzOimt8xCsd2MFDrg2sPvgFkQGyM0ihB9NnNBfiFrQrRP3+DyTCI3TqOfkz8QKe4h7DxefR1t+YvheNZjGtC8C+E= + file_glob: true + file: + - screenshot-* + on: + condition: $TRAVIS_RUST_VERSION = stable + tags: true + skip_cleanup: true notifications: email: false diff --git a/Cargo.toml b/Cargo.toml index a958149..1f3344d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "screenshot" -version = "0.1.0" +version = "0.2.0" authors = ["Michael Zhang "] build = "src/build.rs" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..887d4e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ekidd/rust-musl-builder + +RUN sudo apt-get update -y && sudo apt-get install -y \ + cmake \ + libgles2-mesa-dev \ + libglew-dev \ + libglfw3-dev \ + libglm-dev \ + libgtk-3-dev + +COPY . ./ +RUN sudo chown -R rust:rust . + +CMD cargo build --release diff --git a/ci/build-release.sh b/ci/build-release.sh new file mode 100755 index 0000000..1d1536e --- /dev/null +++ b/ci/build-release.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# 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 + +case `uname -s` in + Linux) + echo "Building static binaries using ekidd/rust-musl-builder" + docker build -t build-"$1"-image . + docker run -it --name build-"$1" build-"$1"-image + docker cp build-"$1":/home/rust/src/target/x86_64-unknown-linux-musl/release/"$1" "$1" + docker rm build-"$1" + docker rmi build-"$1"-image + zip "$1"-"$2".zip "$1" + ;; + *) + echo "Building standard release binaries" + cargo build --release + zip -j "$1"-"$2".zip target/release/"$1" + ;; +esac