diff options
Diffstat (limited to 'ci')
l--------- | ci | 1 | ||||
-rw-r--r-- | ci/.gitattributes | 1 | ||||
-rwxr-xr-x | ci/before_deploy.sh | 166 | ||||
-rwxr-xr-x | ci/before_install.sh | 37 | ||||
-rwxr-xr-x | ci/script.sh | 13 |
5 files changed, 217 insertions, 1 deletions
@@ -1 +0,0 @@ -src/bat/ci
\ No newline at end of file diff --git a/ci/.gitattributes b/ci/.gitattributes new file mode 100644 index 00000000..36eaad9f --- /dev/null +++ b/ci/.gitattributes @@ -0,0 +1 @@ +* linguist-vendored diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100755 index 00000000..22ae7e3a --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,166 @@ +#!/usr/bin/env bash +# Building and packaging for release + +set -ex + +build() { + cargo build --target "$TARGET" --release --verbose +} + +pack() { + local tempdir + local out_dir + local package_name + local gcc_prefix + + tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) + out_dir=$(pwd) + package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET" + + if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then + gcc_prefix="arm-linux-gnueabihf-" + elif [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then + gcc_prefix="aarch64-linux-gnu-" + else + gcc_prefix="" + fi + + # create a "staging" directory + mkdir "$tempdir/$package_name" + + # copying the main binary + cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/" + if [ "$TRAVIS_OS_NAME" != windows ]; then + "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME" + fi + + # manpage, readme and license + cp README.md "$tempdir/$package_name" + cp LICENSE "$tempdir/$package_name" + + # archiving + pushd "$tempdir" + if [ "$TRAVIS_OS_NAME" = windows ]; then + 7z a "$out_dir/$package_name.zip" "$package_name"/* + else + tar czf "$out_dir/$package_name.tar.gz" "$package_name"/* + fi + popd + rm -r "$tempdir" +} + +make_deb() { + local tempdir + local architecture + local version + local dpkgname + local conflictname + local gcc_prefix + local homepage + local maintainer + + homepage="https://github.com/dandavison/delta" + maintainer="Dan Davison <dandavison7@gmail.com>" + + case $TARGET in + x86_64*) + architecture=amd64 + gcc_prefix="" + ;; + i686*) + architecture=i386 + gcc_prefix="" + ;; + aarch64*) + architecture=arm64 + gcc_prefix="aarch64-linux-gnu-" + ;; + arm*hf) + architecture=armhf + gcc_prefix="arm-linux-gnueabihf-" + ;; + *) + echo "make_deb: skipping target '${TARGET}'" >&2 + return 0 + ;; + esac + version=${TRAVIS_TAG#v} + if [[ $TARGET = *musl* ]]; then + dpkgname=$PROJECT_NAME-musl + conflictname=$PROJECT_NAME + else + dpkgname=$PROJECT_NAME + conflictname=$PROJECT_NAME-musl + fi + + tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) + + # copy the main binary + install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME" + "${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME" + + # readme and license + install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md" + install -Dm644 LICENSE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE" + cat > "$tempdir/usr/share/doc/$PROJECT_NAME/copyright" <<EOF +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: $PROJECT_NAME +Source: $homepage + +Files: * +Copyright: $maintainer +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + . + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +EOF + + # Control file + mkdir "$tempdir/DEBIAN" + cat > "$tempdir/DEBIAN/control" <<EOF +Package: $dpkgname +Version: $version +Section: utils +Priority: optional +Maintainer: Dan Davison <dandavison7@gmail.com> +Architecture: $architecture +Provides: $PROJECT_NAME +Conflicts: $conflictname +Description: A syntax highlighter for git. +EOF + + fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb" +} + + +main() { + build + pack + if [[ $TARGET = *linux* ]]; then + make_deb + fi +} + +main diff --git a/ci/before_install.sh b/ci/before_install.sh new file mode 100755 index 00000000..9acf6025 --- /dev/null +++ b/ci/before_install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -ex + +if [ "$TRAVIS_OS_NAME" != linux ]; then + exit 0 +fi + +sudo apt-get update + +# needed for musl targets +sudo apt-get install -y musl-tools + +# needed to build deb packages +sudo apt-get install -y fakeroot + +# needed for i686 linux gnu target +if [[ $TARGET == i686-unknown-linux-gnu ]]; then + sudo apt-get install -y gcc-multilib +fi + +# needed for cross-compiling for arm +if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then + sudo apt-get install -y \ + gcc-4.8-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + libc6-armhf-cross \ + libc6-dev-armhf-cross +fi + +# needed for cross-compiling for arm64 +if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then + sudo apt-get install -y \ + gcc-4.8-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu +fi diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 00000000..3b717e5f --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -ex + +# Incorporate TARGET env var to the build and test process +cargo build --target "$TARGET" --verbose + +# We cannot run arm executables on linux +if [[ $TARGET != arm-unknown-linux-gnueabihf ]] && [[ $TARGET != aarch64-unknown-linux-gnu ]]; then + cargo test --target "$TARGET" --verbose + + cargo run --target "$TARGET" -- < /dev/null +fi |