diff --git a/.github/workflows/push-to-docker.yml b/.github/workflows/push-to-docker.yml index aa62ddc..a4789cc 100644 --- a/.github/workflows/push-to-docker.yml +++ b/.github/workflows/push-to-docker.yml @@ -14,14 +14,25 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Setup Go environment uses: actions/setup-go@v2.1.3 with: go-version: 1.17 + - name: set default tag + run: | + echo "RELEASE_VERSION=dev" >> $GITHUB_ENV + + - name: set tag + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV + - name: Build binary file run: | - export LD_FLAGS="-w -s -X main.VERSION=${COMMIT_ID::7}" + echo ${env.RELEASE_VERSION} + export LD_FLAGS="-w -s -X main.VERSION=${env.RELEASE_VERSION}" go mod tidy go build -o "output/study_xxqg" -trimpath -ldflags "$LD_FLAGS" ./ diff --git a/utils/util.go b/utils/util.go new file mode 100644 index 0000000..a3a0388 --- /dev/null +++ b/utils/util.go @@ -0,0 +1,18 @@ +package utils + +import ( + "os" + "os/exec" +) + +// Restart +/* @Description: + */ +func Restart() { + cmd := exec.Command("./study_xxqg") + go func() { + cmd.Start() + os.Exit(3) + }() + +} diff --git a/web/router.go b/web/router.go index 37c927e..2c3d3f0 100644 --- a/web/router.go +++ b/web/router.go @@ -45,7 +45,7 @@ func RouterInit() *gin.Engine { log.Errorln(err.Error()) f, _ = newUI.ReadFile("app/home.html") } - ctx.Writer.Write(f) + _, _ = ctx.Writer.Write(f) ctx.Status(200) }) // 对权限的管理组