This commit is contained in:
deepzz0
2016-12-25 01:24:34 +08:00
parent c063061482
commit 03282123d4
3 changed files with 29 additions and 16 deletions

View File

@@ -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

View File

@@ -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

13
dist.sh Executable file
View File

@@ -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