This commit is contained in:
影舞者 2023-11-14 23:06:49 +08:00
parent c5adbdb551
commit 0cf8b8c180
2 changed files with 52 additions and 57 deletions

View File

@ -1,69 +1,54 @@
before: before:
hooks: hooks:
- sudo apt -y install libprotobuf-dev protobuf-compiler protoc-gen-go
- go mod tidy - go mod tidy
- go generate ./...
builds: builds:
- id: "with-upx" -
id: default
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
goos: goos:
- linux
- windows - windows
- linux
- darwin - darwin
- freebsd
goarch: goarch:
- amd64 - amd64
- arm64
- arm
- "386" - "386"
goarm:
- "6"
- "7"
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser
ignore:
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
- goos: linux
goarch: mips64
hooks:
post: upx --best -f -q "{{ .Path }}"
# UnknownExecutableFormatException
# CantPackException: can't pack new-exe
- id: "without-upx"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- mips64
- arm - arm
- arm64
- mips
- mipsle
- mips64
goarm: goarm:
- "6" - "6"
- "7" - "7"
flags: flags:
- -trimpath - -trimpath
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser - -s -w
ignore: upx:
- goos: linux -
goarch: arm ids: [ default ]
enabled: true
goos: ["windows", "linux"]
goarch: ["amd64", "386"]
compress: best
lzma: true
brute: true
archives: archives:
- replacements: -
darwin: Darwin format: binary
linux: Linux allow_different_binary_count: true
windows: Windows name_template: >-
386: i386 {{- .ProjectName }}
amd64: x86_64 {{- if eq .Os "darwin"}}_mac
{{- else if eq .Os "linux"}}
{{- else if eq .Os "windows"}}
{{- else }}_{{ .Os }}{{ end }}
{{- if eq .Arch "amd64" }}
{{- else if eq .Arch "386" }}32
{{- else }}_{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot: snapshot:
@ -74,3 +59,5 @@ changelog:
exclude: exclude:
- '^docs:' - '^docs:'
- '^test:' - '^test:'
- "^*.md"
- "^*.ya?ml"

View File

@ -13,23 +13,31 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 60 timeout-minutes: 60
steps: steps:
- - name: "Check out code"
name: Checkout uses: actions/checkout@v3
uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
-
name: Set up Go - name: "Set up Go"
uses: actions/setup-go@v2 uses: actions/setup-go@v4
with: with:
go-version: 1.19 go-version: 1.21.x
- -
name: Run GoReleaser name: Install UPX
uses: goreleaser/goreleaser-action@v2 uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: UPX version
run: upx --version
-
name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v4
with: with:
distribution: goreleaser distribution: goreleaser
version: latest version: latest
args: -f .github/conf/.goreleaser.yml args: "release --clean --debug -f .github/conf/.goreleaser.yml"
workdir: . workdir: .
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}