From 8ef72917da21f8abc5169c11c671327ea84592b5 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 | 79 ++++++++++++++++++++++++++++++++++ core/service/common/label.go | 3 +- 4 files changed, 108 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..86344eb --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,27 @@ +name: Main WorkFlow +on: + push: + tags: + - '*' + +jobs: + release: + 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.GH_PAT }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4922945 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,79 @@ +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: + - id: inkd + binary: inkd + 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 + - id: inker + binary: inker + 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 + - id: inkctl + binary: inkctl + 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: + - id: ink + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + 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"