Skip to content

Commit

Permalink
add travis
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Apr 25, 2018
1 parent 73b3470 commit b0d7222
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: go
sudo: false
notifications:
email: false
jobs:
include:
- go: 1.10.x
stage: deploy
go_import_path: github.com/wzshiming/pic2ascii
install: skip
script: skip
before_deploy:
- ./build_all.bash
deploy:
provider: releases
api_key:
secure: GzblmBWxT2Mrj3Tj7enzGYJkYhpo/dfSyKObGom+C+Y15qRyUWRznyTVIsFSqiMTHVZioLHlQIvrBkR2o41PoFYCeP5xQ/4mEbdoIzjFhpWK8E7Y+WCtd0PLfIVOm2wiZpOy+ucu5KnBYeXyopyFHmTBlVjsUNQwUK4SdEE6RWlZB6rN8FHaF+KzW4hikDVHPSdZ0b49WsTNkSyToD8t9vnTFKrMMpfgwBJCJKpg+IADhz15/LESbGq/zNZWirZ1x6UtAez0gcc4VOMNNILbMu76Ldb0WVyHcnnkp+wXMacWxezxqTsKt70/483p6M8TLXIRR0WFPAHIerEOpodPxea4KJaSh8idZGnchL0NeaHpLG+sCEvwxrwHy666kVLpmEjnPEsSK4FvF7e04LFauPVYDJmgu44eUXqaSu/8o0Gv/cr9vWa0JrUWbGgzWFL+h3W53Qzkna98adBMfe1M2z8msMbT2fNWmsmgYPK6HZ4DM+QANc3DyomSOUf8LIEYRxxD7PKaTcjaJGXMF+/tpwnz51yotOX5ddh/QJXxOi+36lxV3EoWcJ8u/XsPnnEn6fmXkp6JmsjuFZsQgG8JaVOwAOeoa4cTzGWgTCmf8sQHMgJ6cm6VDY9C8XGjOaQaWKtwqmu6dEeqybYFTNZtBJHXZ2eOtyfXNWEYt1lqsbo=
file_glob: true
file: release/*
skip_cleanup: true
on:
repo: wzshiming/pic2ascii
branch: master
tags: true
41 changes: 41 additions & 0 deletions build_all.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -e

BASENAME=pic2ascii
SRC_ROOT=$(git rev-parse --show-toplevel)
VERSION=$(git describe --tags --dirty)
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
DATE=$(date "+%Y-%m-%d")
IMPORT_DURING_SOLVE=${IMPORT_DURING_SOLVE:-false}

if [[ "$(pwd)" != "${SRC_ROOT}" ]]; then
echo "you are not in the root of the repo" 1>&2
echo "please cd to ${SRC_ROOT} before running this script" 1>&2
exit 1
fi

GO_BUILD_CMD="go build -a -installsuffix cgo"
GO_BUILD_LDFLAGS="-s -w -X main.commitHash=${COMMIT_HASH} -X main.buildDate=${DATE} -X main.version=${VERSION} -X main.flagImportDuringSolve=${IMPORT_DURING_SOLVE}"

if [[ -z "${SRC_BUILD_PLATFORMS}" ]]; then
SRC_BUILD_PLATFORMS="linux windows darwin freebsd"
fi

if [[ -z "${SRC_BUILD_ARCHS}" ]]; then
SRC_BUILD_ARCHS="amd64 386"
fi

mkdir -p "${SRC_ROOT}/release"

for OS in ${SRC_BUILD_PLATFORMS[@]}; do
for ARCH in ${SRC_BUILD_ARCHS[@]}; do
NAME="${BASENAME}_${OS}_${ARCH}"
if [[ "${OS}" == "windows" ]]; then
NAME="${NAME}.exe"
fi
echo "Building for ${OS}/${ARCH}"
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=0 ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\
-o "${SRC_ROOT}/release/${NAME}" ./cmd/${BASENAME}
shasum -a 256 "${SRC_ROOT}/release/${NAME}" > "${SRC_ROOT}/release/${NAME}".sha256
done
done

0 comments on commit b0d7222

Please sign in to comment.