From 801caa38415929d3f83dfdcd3f49e4c790d434b4 Mon Sep 17 00:00:00 2001 From: samwaf Date: Fri, 2 Aug 2024 15:58:20 +0800 Subject: [PATCH] =?UTF-8?q?build:=E6=B5=8B=E8=AF=95=20goreleaser=E5=8F=91?= =?UTF-8?q?=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/goreleaser.yml | 34 ++++++++++++ .gitignore | 3 +- .goreleaser.yaml | 89 ++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/goreleaser.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..bc0b3bd --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +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@v4 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2dfb3a6..d8d3210 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ /data/local_log.db-wal /data/local_stats.db-shm /data/local_stats.db-wal -registration_data.bin \ No newline at end of file +registration_data.bin +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..ed7f42f --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,89 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - id: "samwaf" + env: + - CGO_ENABLED=1 + - GOPROXY=https://goproxy.cn,direct + goos: + - windows + goarch: + - amd64 + ldflags: + - -X SamWaf/global.GWAF_RELEASE=true + - -X SamWaf/global.GWAF_RELEASE_VERSION_NAME={{ time "20060102" }} + - -X SamWaf/global.GWAF_RELEASE_VERSION={{.Tag}} + - -s -w + - -extldflags "-static" +upx: + - # Whether to enable it or not. + # + # Templates: allowed. + enabled: false + + # Filter by build ID. + ids: [samwaf] + + # Filter by GOOS. + goos: [windows] + + # Filter by GOARCH. + goarch: [amd64] + + # Filter by GOAMD64. + goamd64: [v1] + + # Compress argument. + # Valid options are from '1' (faster) to '9' (better), and 'best'. + compress: best + + # Whether to try LZMA (slower). + lzma: true + + # Whether to try all methods and filters (slow). + brute: true +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }}_ + {{.Tag}} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +changelog: + sort: asc + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: "Bug fixes" + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: Others + order: 999 + filters: + exclude: + - "^docs:" + - "^test:"