From 68d0048148748493dc2732a8b3a2251767f34d2d Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Fri, 9 Feb 2018 00:44:13 +0100 Subject: Build static binaries and deploy to GH Releases from Travis --- .travis.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/.travis.yml b/.travis.yml index 99914b94..3ec64674 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,14 @@ sudo: false language: c +stages: + - name: test + + - name: build + # Don't run build stage for pull requests to save time and resources. + if: type != pull_request + + jobs: include: # Build with gcc and run tests on Ubuntu. @@ -139,6 +147,56 @@ jobs: - alpine make check + # Build release binary statically linked with musl libc on Alpine Linux + # (inside chroot). If building a tagged commit, then deploy release + # tarball to GitHub Releases. + - &build-alpine + <<: *test-alpine + stage: build + env: ARCH=x86_64 + + script: + - alpine ./configure --disable-docs --enable-all-static + CFLAGS='-Os -static -no-pie' CXXFLAGS='-Os -static -no-pie' + - alpine make + - alpine strip jq + + - jq -V + - ls -lah jq + - file jq + # Ensure that the built executable is really statically linked. + - file jq | grep -Fw 'statically linked' + + before_deploy: + - PKGNAME="jq-$TRAVIS_TAG-$ARCH-linux" + - mkdir $PKGNAME && mv jq $PKGNAME/ + - tar -czf $PKGNAME.tar.gz $PKGNAME/ + - sha256sum $PKGNAME.tar.gz > $PKGNAME.tar.gz.sha256 + + deploy: + provider: releases + api_key: + secure: # TODO: put encrypted GitHub token here! + file: jq-$TRAVIS_TAG-*.tar.gz* + file_glob: true + skip_cleanup: true + on: + tags: true + + # Build binaries for other architectures using QEMU user-mode emulation. + - <<: *build-alpine + env: ARCH=x86 + + - <<: *build-alpine + env: ARCH=aarch64 + + - <<: *build-alpine + env: ARCH=armhf + + - <<: *build-alpine + env: ARCH=ppc64le + + notifications: email: false -- cgit v1.2.3