From 5c21a8e4c12485a6bd376a92aa3ee0aa4ada5581 Mon Sep 17 00:00:00 2001 From: zc Date: Mon, 4 Mar 2024 20:04:01 +0800 Subject: [PATCH] add release ci --- .github/workflows/main.yaml | 3 +- .github/workflows/release.yaml | 27 +++++++++++++ .goreleaser.yaml | 72 ++++++++++++++++++++++++++++++++++ core/service/common/label.go | 3 +- 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e4df727..fa4f5dc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,7 +3,6 @@ on: push: branches: - main - tags: pull_request: jobs: @@ -21,7 +20,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v4 with: - version: v1.54.2 + version: v1.54 - name: Install Dependencies run: go get -v -t -d ./... diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ca05c23 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,27 @@ +name: Main WorkFlow +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.21.0 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: v1.24.0 + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..6d2a84c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,72 @@ +before: + hooks: + - go mod tidy + +gomod: + proxy: true + env: + - GOPROXY=https://goproxy.cn,https://goroxy.io,https://proxy.golang.org,direct + - GOSUMDB=sum.golang.org + mod: mod + +builds: + - main: ./cmd/inkd + env: + - CGO_ENABLED=0 + - >- + {{- if eq .Os "darwin" }} + {{- if eq .Arch "amd64"}}CC=o64-clang{{- end }} + {{- if eq .Arch "arm64"}}CC=aarch64-apple-darwin20.2-clang{{- end }} + {{- end }} + {{- if eq .Os "windows" }} + {{- if eq .Arch "amd64" }}CC=x86_64-w64-mingw32-gcc{{- end }} + {{- end }} + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + - main: ./cmd/inker + env: + - CGO_ENABLED=0 + - >- + {{- if eq .Os "darwin" }} + {{- if eq .Arch "amd64"}}CC=o64-clang{{- end }} + {{- if eq .Arch "arm64"}}CC=aarch64-apple-darwin20.2-clang{{- end }} + {{- end }} + {{- if eq .Os "windows" }} + {{- if eq .Arch "amd64" }}CC=x86_64-w64-mingw32-gcc{{- end }} + {{- end }} + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + - main: ./cmd/inkctl + env: + - CGO_ENABLED=0 + - >- + {{- if eq .Os "darwin" }} + {{- if eq .Arch "amd64"}}CC=o64-clang{{- end }} + {{- if eq .Arch "arm64"}}CC=aarch64-apple-darwin20.2-clang{{- end }} + {{- end }} + {{- if eq .Os "windows" }} + {{- if eq .Arch "amd64" }}CC=x86_64-w64-mingw32-gcc{{- end }} + {{- end }} + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + +archives: + - name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}' + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' diff --git a/core/service/common/label.go b/core/service/common/label.go index ed97b69..e954a16 100644 --- a/core/service/common/label.go +++ b/core/service/common/label.go @@ -19,9 +19,8 @@ import ( "fmt" "strings" - "gorm.io/gorm" - "github.com/99nil/gopkg/sets" + "gorm.io/gorm" storageV1 "github.com/zc2638/ink/pkg/api/storage/v1" "github.com/zc2638/ink/pkg/database"