diff --git a/.gitignore b/.gitignore index 98177ad119563741f3f98217342cdf72efaa8e4a..3f4ba17088fb1944c53ae64ceeac042c938af99e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.dylib *.db *.bin +/release/ # Test binary, build with `go test -c` *.test diff --git a/.travis.yml b/.travis.yml index a0f934051ac3b9f29acd936421442a8f2aa76625..c9d055028c22584eeb40641df693cdb841215361 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,12 @@ go: - 1.13.x git: depth: 1 -script: - - go test -coverprofile=coverage.txt -covermode=atomic ./... -after_success: - - bash <(curl -s https://codecov.io/bash) +install: + - sudo apt install gcc-mingw-w64 + - chmod +x ./build.sh +script: + - ./build.sh -r b +# script: +# - go test -coverprofile=coverage.txt -covermode=atomic ./... +# after_success: +# - bash <(curl -s https://codecov.io/bash) diff --git a/build.sh b/build.sh index 45d7cfc71fcb0a75511401d76d36f8f57f4857ad..cc87797b166fc5732bd0352679b94969d4e2a3d9 100755 --- a/build.sh +++ b/build.sh @@ -26,6 +26,7 @@ buildAssets () { yarn run build if ! [ -x "$(command -v statik)" ]; then + export CGO_ENABLED=0 go get github.com/rakyll/statik fi @@ -43,21 +44,34 @@ _build() { IFS=/ read -r -a arr <<<"$osarch" os="${arr[0]}" arch="${arr[1]}" + gcc="${arr[2]}" # Go build to build the binary. export GOOS=$os export GOARCH=$arch - - go build -a -o cloudreve_$VERSION_$GOOS_$GOARCH -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" + export CC=$gcc + export CGO_ENABLED=1 + + out="release/cloudreve_${VERSION}_${os}_${arch}" + go build -a -o "${out}" -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" + + if [ "$os" = "windows" ]; then + mv $out release/cloudreve.exe + zip -j -q "${out}.zip" release/cloudreve.exe + rm -f "release/cloudreve.exe" + else + mv $out release/cloudreve + tar -zcvf "${out}.tar.gz" -C release cloudreve + rm -f "release/cloudreve" + fi } release(){ cd $REPO - export CGO_ENABLED=1 ## List of architectures and OS to test coss compilation. - SUPPORTED_OSARCH="linux/arm64 darwin/amd64 windows/amd64 linux/arm linux/386 windows/386" + SUPPORTED_OSARCH="linux/amd64/gcc linux/arm/arm-linux-gnueabihf-gcc windows/amd64/x86_64-w64-mingw32-gcc" - echo "Release builds for OS/Arch: ${SUPPORTED_OSARCH}" + echo "Release builds for OS/Arch/CC: ${SUPPORTED_OSARCH}" for each_osarch in ${SUPPORTED_OSARCH}; do _build "${each_osarch}" done @@ -81,7 +95,7 @@ while getopts "bacr:d" o; do BINARY="true" ;; r) - ASSETS="true" + # ASSETS="true" RELEASE="true" ;; d) @@ -108,4 +122,4 @@ fi if [ "$RELEASE" = "true" ]; then release -fi +fi \ No newline at end of file diff --git a/pkg/util/logger.go b/pkg/util/logger.go index d3326878f2490576744a2fa1a2beb26a3f52b200..81e365289affba5f30ab83a1624ddd73574d7170 100644 --- a/pkg/util/logger.go +++ b/pkg/util/logger.go @@ -46,7 +46,7 @@ var spaces = map[string]string{ // Println 打印 func (ll *Logger) Println(prefix string, msg string) { // TODO Release时去掉 - color.NoColor = false + // color.NoColor = false c := color.New() _, _ = c.Printf(