From 8734486c48497a2701a4a91162d9b5e9b02db915 Mon Sep 17 00:00:00 2001 From: wweir Date: Sat, 19 Jan 2019 11:57:03 +0800 Subject: [PATCH] Add CI release support --- .circleci/config.yml | 32 +++++++++++++++++++++++++++----- README.md | 3 ++- shadow/cipher.go | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f2a5cef..46c372f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,16 +7,38 @@ jobs: - checkout # check out the code in the project directory - setup_remote_docker # install docker in docker - run: - name: build linux binary + name: Prepare Environment + command: | + cp conf/sower.toml . + cp deploy/* . + mkdir artifacts + - run: + name: build linux Binary command: | make build - mv sower sower.linux + tar czvf artifacts/sower-linux.tar.gz sower sower.toml - run: - name: build macOS binary + name: build macOS Binary command: | GOOS=darwin GOARCH=amd64 make build - mv sower sower.darwin + tar czvf artifacts/sower-darwin.tar.gz sower sower.toml + - run: + name: build Windows Binary + command: | + GOOS=windows GOARCH=amd64 make build + tar czvf artifacts/sower-windows.tar.gz sower sower.toml + - run: + name: Publish Release on GitHub + command: | + go get github.com/tcnksm/ghr + VERSION=$(git describe --tags) + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION%-*-*} artifacts/ - run: name: build docker image command: | - make image \ No newline at end of file + docker login -u $DOCKER_USER -p $DOCKER_PASS + make image + VERSION=$(git describe --tags) + docker tag sower:latest sower:${VERSION%-*-*} + docker push sower:${VERSION%-*-*} + docker push sower:latest \ No newline at end of file diff --git a/README.md b/README.md index aed43e0..77fbe71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # sower +[![CircleCI](https://circleci.com/gh/wweir/sower.svg?style=svg)](https://circleci.com/gh/wweir/sower) Yet another cross platform transparent proxy tool ## architecture @@ -46,6 +47,6 @@ http(s) proxy | +----------+ | | ## todo - [x] authenticate - [ ] broker -- [ ] CI/CD +- [x] CI/CD - [ ] relay optimization - [ ] deploy script for all normal platform \ No newline at end of file diff --git a/shadow/cipher.go b/shadow/cipher.go index 278dc8c..262a578 100644 --- a/shadow/cipher.go +++ b/shadow/cipher.go @@ -54,7 +54,7 @@ func pickCipher(cipherType, password string) (cipher.AEAD, error) { func genKey(filler string, size int) []byte { res := make([]byte, size) if filler == "" { - filler = "default_filler" + panic("password should not be empty") } fillerByte := []byte(filler)