x
This commit is contained in:
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
@@ -12,11 +12,14 @@ jobs:
|
||||
release:
|
||||
name: Release Binary
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: goreleaser/goreleaser-cross:v1.24
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: git config --global --add safe.directory "$(pwd)"
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
@@ -36,16 +39,8 @@ jobs:
|
||||
with:
|
||||
install-only: true
|
||||
|
||||
- name: Build Package
|
||||
run: |
|
||||
./script/package.sh
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
- name: Run GoReleaser
|
||||
run: goreleaser release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
files: packages/*
|
||||
draft: true
|
||||
prerelease: true
|
||||
ENABLE_UPX: true
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -28,4 +28,5 @@ go.work.sum
|
||||
.stfolder
|
||||
|
||||
chatlog
|
||||
chatlog.exe
|
||||
chatlog.exe# Added by goreleaser init:
|
||||
dist/
|
||||
|
||||
90
.goreleaser.yaml
Normal file
90
.goreleaser.yaml
Normal file
@@ -0,0 +1,90 @@
|
||||
# GoReleaser v2 配置
|
||||
version: 2
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- id: darwin-amd64
|
||||
binary: chatlog
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=o64-clang
|
||||
- CXX=o64-clang++
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
ldflags:
|
||||
- -s -w -X github.com/sjzar/chatlog/pkg/version.Version={{.Version}}
|
||||
|
||||
- id: darwin-arm64
|
||||
binary: chatlog
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=oa64-clang
|
||||
- CXX=oa64-clang++
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- arm64
|
||||
ldflags:
|
||||
- -s -w -X github.com/sjzar/chatlog/pkg/version.Version={{.Version}}
|
||||
|
||||
- id: windows-amd64
|
||||
binary: chatlog
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=x86_64-w64-mingw32-gcc
|
||||
- CXX=x86_64-w64-mingw32-g++
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
ldflags:
|
||||
- -s -w -X github.com/sjzar/chatlog/pkg/version.Version={{.Version}}
|
||||
|
||||
- id: windows-arm64
|
||||
binary: chatlog
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc
|
||||
- CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
- arm64
|
||||
ldflags:
|
||||
- -s -w -X github.com/sjzar/chatlog/pkg/version.Version={{.Version}}
|
||||
|
||||
archives:
|
||||
- id: default
|
||||
format: tar.gz
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- .Version }}_
|
||||
{{- .Os }}_
|
||||
{{- .Arch }}
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
|
||||
upx:
|
||||
- enabled: "{{ .Env.ENABLE_UPX }}"
|
||||
goos: [darwin, windows]
|
||||
goarch: [amd64]
|
||||
compress: best
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
algorithm: sha256
|
||||
|
||||
# 配置 GitHub Release
|
||||
release:
|
||||
draft: true
|
||||
prerelease: auto
|
||||
mode: replace
|
||||
4
Makefile
4
Makefile
@@ -38,7 +38,7 @@ test:
|
||||
|
||||
build:
|
||||
@echo "🔨 Building for current platform..."
|
||||
$(GO) build -trimpath $(LDFLAGS) -o bin/$(BINARY_NAME) main.go
|
||||
CGO_ENABLED=1 $(GO) build -trimpath $(LDFLAGS) -o bin/$(BINARY_NAME) main.go
|
||||
|
||||
crossbuild: clean
|
||||
@echo "🌍 Building for multiple platforms..."
|
||||
@@ -50,7 +50,7 @@ crossbuild: clean
|
||||
[ "$$float" != "" ] && output_name=$$output_name_$$float; \
|
||||
echo "🔨 Building for $$os/$$arch..."; \
|
||||
echo "🔨 Building for $$output_name..."; \
|
||||
GOOS=$$os GOARCH=$$arch GOARM=$$float $(GO) build -trimpath $(LDFLAGS) -o $$output_name main.go ; \
|
||||
GOOS=$$os GOARCH=$$arch CGO_ENABLED=1 GOARM=$$float $(GO) build -trimpath $(LDFLAGS) -o $$output_name main.go ; \
|
||||
if [ "$(ENABLE_UPX)" = "1" ] && echo "$(UPX_PLATFORMS)" | grep -q "$$os/$$arch"; then \
|
||||
echo "⚙️ Compressing binary $$output_name..." && upx --best $$output_name; \
|
||||
fi; \
|
||||
|
||||
Reference in New Issue
Block a user