diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1db99b..038d55a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,5 +29,15 @@ jobs: with: cache: false go-version-file: go.mod + + - name: Verify gofmt + run: | + make fmt && git add azure util cmd constant && + git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1); + - name: Verify govet + run: | + make vet && git add azure util cmd constant && + git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1); + - name: Build run: make build \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c685c53..22400b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,4 +55,27 @@ jobs: ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} # https://docs.docker.com/build/cache/backends/gha/ cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max + + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Fetch all tags + run: git fetch --force --tags + - name: Set up Go + uses: actions/setup-go@v4 + with: + cache: false + go-version-file: go.mod + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index edcf14c..b8d2574 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,7 +1,9 @@ # Make sure to check the documentation at https://goreleaser.com +project_name: azure-openai-proxy +env: + - GIT_URL=https://github.com/stulzq/azure-openai-proxy before: hooks: - # You may remove this if you don't use go modules. - go mod tidy builds: - id: azure-openai-proxy diff --git a/Makefile b/Makefile index f5b3fcb..283060a 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,10 @@ BIN_NAME := "azure-openai-proxy" build: @env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/$(BIN_NAME) ./cmd -.PHONY: build \ No newline at end of file +fmt: + go fmt ./... + +vet: + go vet ./... + +.PHONY: build fmt vet \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index 607c4db..6da5007 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -45,7 +45,7 @@ func runServer(srv *http.Server) { } }() - quit := make(chan os.Signal) + quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit