From 389c1739ff611ec02e1f49b6985bf94e1fda3ff2 Mon Sep 17 00:00:00 2001 From: zwwhdls Date: Thu, 27 Jun 2024 23:22:21 +0800 Subject: [PATCH] add goreleaser workflow Signed-off-by: zwwhdls --- .github/workflows/release.yaml | 30 +++++++++++++++++++++ .goreleaser.yaml | 48 +++++++++++++++++++++++++++++++++ .goreleaser.yml | 49 ---------------------------------- 3 files changed, 78 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml delete mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..a06637a0 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,30 @@ +name: goreleaser + +on: + release: + types: + - created + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..6b6e1308 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,48 @@ +project_name: nanafs +env: + - GO111MODULE=on + - CGO_ENABLED=0 +before: + hooks: + - go mod download +builds: + - id: nanafs-darwin-amd64 + ldflags: -s -w -X config.gitCommit={{.ShortCommit}} -X config.gitTag={{.Version}} + main: . + goos: + - darwin + goarch: + - amd64 + - id: nanafs-darwin-arm64 + ldflags: -s -w -X config.gitCommit={{.ShortCommit}} -X config.gitTag={{.Version}} + main: . + goos: + - darwin + goarch: + - arm64 + - id: nanafs-linux-amd64 + ldflags: -s -w -X config.gitCommit={{.ShortCommit}} -X config.gitTag={{.Version}} + main: . + goos: + - linux + goarch: + - amd64 + - id: nanafs-linux-arm64 + ldflags: -s -w -X config.gitCommit={{.ShortCommit}} -X config.gitTag={{.Version}} + main: . + goos: + - linux + goarch: + - arm64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +archives: + - name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 903e9e7c..00000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,49 +0,0 @@ -project_name: nanafs -env: - - GO111MODULE=on - - CGO_ENABLED=1 - - REVISIONDATE={{ .Env.REVISIONDATE }} -before: - hooks: - - go mod download -builds: - - id: nanafs-darwin-amd64 - ldflags: -s -w -X github.com/basenana/nanafs/version.gitCommit={{.ShortCommit}} -X github.com/basenana/nanafs/version.gitTag={{.Version}} -X github.com/basenana/nanafs/version.revisionDate={{.Env.REVISIONDATE}} - main: . - goos: - - darwin - goarch: - - amd64 - - id: nanafs-darwin-arm64 - ldflags: -s -w -X github.com/basenana/nanafs/version.gitCommit={{.ShortCommit}} -X github.com/basenana/nanafs/version.gitTag={{.Version}} -X github.com/basenana/nanafs/version.revisionDate={{.Env.REVISIONDATE}} - main: . - goos: - - darwin - goarch: - - arm64 - - id: nanafs-linux-amd64 - ldflags: -s -w -X github.com/basenana/nanafs/version.gitCommit={{.ShortCommit}} -X github.com/basenana/nanafs/version.gitTag={{.Version}} -X github.com/basenana/nanafs/version.revisionDate={{.Env.REVISIONDATE}} - main: . - goos: - - linux - goarch: - - amd64 - - id: nanafs-linux-arm64 - ldflags: -s -w -X github.com/basenana/nanafs/version.gitCommit={{.ShortCommit}} -X github.com/basenana/nanafs/version.gitTag={{.Version}} -X github.com/basenana/nanafs/version.revisionDate={{.Env.REVISIONDATE}} - main: . - goos: - - linux - goarch: - - arm64 -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' -archives: - - name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"