From ee6c4f1b5c34398f7a95155e9a03e08b2dd2c0ef Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Thu, 6 May 2021 15:30:31 +0800 Subject: [PATCH] rewrite github action script --- .github/workflows/go.yml | 31 ++++++++------------------- scripts/ci_release.sh | 46 ---------------------------------------- scripts/make_release.sh | 29 +++++++++++++++---------- 3 files changed, 27 insertions(+), 79 deletions(-) delete mode 100755 scripts/ci_release.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 813ee056..2b90fea7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -33,38 +33,25 @@ jobs: - name: Get dependencies run: | - go get -v -u github.com/shuLhan/go-bindata/... go get -v -t -d ./... - name: Build run: | - #bash scripts/ci_release.sh windows amd64 - #bash scripts/ci_release.sh windows 386 - bash scripts/ci_release.sh linux amd64 - bash scripts/ci_release.sh linux 386 - bash scripts/ci_release.sh linux arm64 - # bash scripts/ci_release.sh linux arm - # bash scripts/ci_release.sh linux mipsle - # bash scripts/ci_release.sh linux mips - # bash scripts/ci_release.sh darwin amd64 + bash scripts/make_release.sh gzip amd64 + bash scripts/make_release.sh gzip amd64 purego + bash scripts/make_release.sh gzip arm64 + bash scripts/make_release.sh gzip arm64 purego - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | - #scripts/build/cloud-torrent_windows_amd64.exe.gz - #scripts/build/cloud-torrent_windows_386.exe.gz - scripts/build/cloud-torrent_linux_amd64.gz - scripts/build/cloud-torrent_linux_386.gz - scripts/build/cloud-torrent_linux_arm64.gz - # scripts/build/cloud-torrent_linux_arm_armv5.gz - # scripts/build/cloud-torrent_linux_arm_armv6.gz - # scripts/build/cloud-torrent_linux_arm_armv7.gz - # scripts/build/cloud-torrent_linux_mipsle.gz - # scripts/build/cloud-torrent_linux_mips.gz - # scripts/build/cloud-torrent_darwin_amd64.gz - prerelease: false + cloud-torrent_linux_amd64.gz + cloud-torrent_linux_amd64_static.gz + cloud-torrent_linux_arm64.gz + cloud-torrent_linux_arm64_static.gz + prerelease: true draft: false body_path: gittaglogs.txt env: diff --git a/scripts/ci_release.sh b/scripts/ci_release.sh deleted file mode 100755 index 1f75504a..00000000 --- a/scripts/ci_release.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" -__base="$(basename ${__file} .sh)" -__root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on your app - -BUILDDIR=$__dir/build -BIN=cloud-torrent -mkdir -p $BUILDDIR -GITVER=$(git describe --tags) - -makebuild () { - local PREFIX=$1 - local OS=$2 - local ARCH=$3 - local SUFFIX= - if [[ ${OS} == "windows" ]]; then - SUFFIX=".exe" - fi - BINFILE=${BIN}_${OS}_${ARCH}${SUFFIX} - - if [[ ${ARCH} == "arm" ]]; then - for GM in 5 6 7; do - SUFFIX="_armv${GM}" - BINFILE=${BIN}_${OS}_${ARCH}${SUFFIX} - GOARCH=$ARCH GOARM=${GM} GOOS=$OS go build -o ${BUILDDIR}/${BINFILE} -trimpath -ldflags "-s -w -X main.VERSION=$GITVER" - pushd ${BUILDDIR} - gzip -v -9 ${BINFILE} - popd - done - else - GOARCH=$ARCH GOOS=$OS go build -o ${BUILDDIR}/${BINFILE} -trimpath -ldflags "-s -w -X main.VERSION=$GITVER" - pushd ${BUILDDIR} - gzip -v -9 ${BINFILE} - popd - fi -} - -upstatic () { - pushd $__dir/../static - env PATH=$HOME/go/bin:$PATH bash generate.sh - popd -} - -upstatic -makebuild $BIN $1 $2 diff --git a/scripts/make_release.sh b/scripts/make_release.sh index 6e1da08c..19b53031 100755 --- a/scripts/make_release.sh +++ b/scripts/make_release.sh @@ -9,32 +9,38 @@ GITVER=$(git describe --tags) OS="" ARCH="" -EXESUFFIX="" +SUFFIX="" PKGCMD= NOSTATIC= CGO=1 for arg in "$@"; do case $arg in + amd64) + ARCH=amd64 + ;; + arm64) + ARCH=arm64 + ;; 386) - GOARCH=386 + ARCH=386 ;; windows) OS=windows - EXESUFFIX=.exe + SUFFIX=.exe ;; xz) PKGCMD=xz - ;; + ;; nostat) NOSTATIC=1 - ;; + ;; gzip) PKGCMD=gzip ;; purego) CGO=0 - EXESUFFIX=_static + SUFFIX=_static ;; esac done @@ -56,15 +62,16 @@ fi pushd $__dir/.. BINFILE=${BIN}_${OS}_${ARCH}${SUFFIX} -rm -fv ${BIN}_* -CGO_ENABLED=$CGO GOARCH=$ARCH GOOS=$OS go build -o ${BINFILE}${EXESUFFIX} -trimpath -ldflags "-s -w -X main.VERSION=$GITVER" -if [[ ! -f ${BINFILE}${EXESUFFIX} ]]; then +CGO_ENABLED=$CGO GOARCH=$ARCH GOOS=$OS go build -o ${BINFILE} -trimpath -ldflags "-s -w -X main.VERSION=$GITVER" +if [[ ! -f ${BINFILE} ]]; then echo "Build failed. Check with error message above." exit 1 fi -git checkout HEAD -- static/* +if [[ -z $NOSTATIC ]]; then + git checkout HEAD -- static/* +fi if [[ ! -z $PKGCMD ]]; then - ${PKGCMD} -v -9 -k ${BINFILE}${EXESUFFIX} + ${PKGCMD} -v -9 ${BINFILE} fi