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: release:
name: Release Binary name: Release Binary
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: goreleaser/goreleaser-cross:v1.24
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- run: git config --global --add safe.directory "$(pwd)"
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v4
@@ -36,16 +39,8 @@ jobs:
with: with:
install-only: true install-only: true
- name: Build Package - name: Run GoReleaser
run: | run: goreleaser release --clean
./script/package.sh
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: ENABLE_UPX: true
files: packages/*
draft: true
prerelease: true

3
.gitignore vendored
View File

@@ -28,4 +28,5 @@ go.work.sum
.stfolder .stfolder
chatlog 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: build:
@echo "🔨 Building for current platform..." @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 crossbuild: clean
@echo "🌍 Building for multiple platforms..." @echo "🌍 Building for multiple platforms..."
@@ -50,7 +50,7 @@ crossbuild: clean
[ "$$float" != "" ] && output_name=$$output_name_$$float; \ [ "$$float" != "" ] && output_name=$$output_name_$$float; \
echo "🔨 Building for $$os/$$arch..."; \ echo "🔨 Building for $$os/$$arch..."; \
echo "🔨 Building for $$output_name..."; \ 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 \ if [ "$(ENABLE_UPX)" = "1" ] && echo "$(UPX_PLATFORMS)" | grep -q "$$os/$$arch"; then \
echo "⚙️ Compressing binary $$output_name..." && upx --best $$output_name; \ echo "⚙️ Compressing binary $$output_name..." && upx --best $$output_name; \
fi; \ fi; \

View File

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