This commit is contained in:
Shen Junzheng
2025-03-25 10:04:08 +08:00
parent 80c7e67106
commit 3f673cbd7e
5 changed files with 101 additions and 15 deletions

View File

@@ -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
View File

@@ -28,4 +28,5 @@ go.work.sum
.stfolder
chatlog
chatlog.exe
chatlog.exe# Added by goreleaser init:
dist/

90
.goreleaser.yaml Normal file
View 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

View File

@@ -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; \

View File

@@ -54,7 +54,7 @@ go install github.com/sjzar/chatlog@latest
3. 下载 `chatlog` 预编译版本或从源码安装,推荐使用 go 进行安装。
4. 运行 `chatlog`,按照提示进行操作,解密数据开启 HTTP 服务后,即可通过浏览器或 AI 助手访问聊天记录。
4. 运行 `chatlog`,按照提示进行操作,解密数据开启 HTTP 服务后,即可通过浏览器或 AI 助手访问聊天记录。
### macOS 版本提示