From 03282123d467e868a4366f843bcb0bba9da4e4f1 Mon Sep 17 00:00:00 2001 From: deepzz0 Date: Sun, 25 Dec 2016 01:24:34 +0800 Subject: [PATCH] update --- .travis.yml | 22 ++++++++++++++++------ before_deploy.sh | 10 ---------- dist.sh | 13 +++++++++++++ 3 files changed, 29 insertions(+), 16 deletions(-) delete mode 100755 before_deploy.sh create mode 100755 dist.sh diff --git a/.travis.yml b/.travis.yml index f0e7346..9f74cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,33 @@ sudo: required # 超级权限 + dist: trusty # 在ubuntu:trusty + notifications: # 每次构建的时候是否通知,如果不想收到通知邮箱(个人感觉邮件贼烦),那就设置false吧 email: false + language: go # 声明构建语言环境 + go: # 只构建最新版本 - tip + services: # docker环境 - docker + branches: # 限定项目分支 only: - master + before_install: - curl https://glide.sh/get | sh # 安装glide包管理 + script: - glide up - GOOS=linux GOARCH=amd64 go build # 编译版本 - docker build -t registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog . # 构建镜像 -after_success: - - if [ "$TRAVIS_BRANCH" == "master" ]; then - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" registry.cn-hangzhou.aliyuncs.com; - docker push registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog; - fi # push到镜像仓库 before_deploy: - - ./before_deploy.sh + - ./dist.sh + deploy: provider: releases api_key: @@ -35,3 +39,9 @@ deploy: tags: true repo: eiblog/eiblog all_branches: true + +after_success: + - if [ "$TRAVIS_BRANCH" == "master" ]; then + docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" registry.cn-hangzhou.aliyuncs.com; + docker push registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog; + fi diff --git a/before_deploy.sh b/before_deploy.sh deleted file mode 100755 index ea9c372..0000000 --- a/before_deploy.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -VERSION=`git describe --tags` -tar zcvf eiblog-$VERSION-linux-amd64.tar.gz conf static views eiblog - -GOOS=windows GOARCH=amd64 go build && \ -tar zcvf eiblog-$VERSION-windows-amd64.tar.gz conf static views eiblog - -GOOS=darwin GOARCH=amd64 go build && \ -tar zcvf eiblog-$VERSION-darwin-amd64.tar.gz conf static views eiblog diff --git a/dist.sh b/dist.sh new file mode 100755 index 0000000..4bf34bd --- /dev/null +++ b/dist.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# GOFLAGS='-ldflags="-s -w"' +version=`git describe --tags` +arch=$(go env GOARCH) + +for os in linux darwin windows; do + echo "... building $version for $os/$arch" + TARGET="eiblog-$version.$os-$arch" + GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build + tar czvf $TARGET.tar.gz conf static views eiblog + rm eiblog +done