Skip to content

Commit c5e9f67

Browse files
committed
add release
1 parent 822eab4 commit c5e9f67

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # 当推送以v开头的标签时触发,例如V20260612.0
7+
8+
permissions:
9+
contents: write # 需要这个权限来创建release和上传文件
10+
11+
jobs:
12+
build:
13+
name: Build and Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.23' # 使用较新的Go版本,可以根据需要调整
24+
check-latest: true
25+
26+
- name: Get tag name
27+
id: get_tag
28+
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
29+
30+
- name: Build binaries
31+
run: |
32+
# 创建build目录存放二进制文件
33+
mkdir -p builds
34+
35+
# macOS (Intel)
36+
GOOS=darwin GOARCH=amd64 go build -o builds/tiny-requestbin-${{ env.TAG }}-darwin-amd64 .
37+
38+
# macOS (Apple Silicon)
39+
GOOS=darwin GOARCH=arm64 go build -o builds/tiny-requestbin-${{ env.TAG }}-darwin-arm64 .
40+
41+
# Linux (x86_64)
42+
GOOS=linux GOARCH=amd64 go build -o builds/tiny-requestbin-${{ env.TAG }}-linux-amd64 .
43+
44+
# Linux (ARM64)
45+
GOOS=linux GOARCH=arm64 go build -o builds/tiny-requestbin-${{ env.TAG }}-linux-arm64 .
46+
47+
# Windows (x86_64)
48+
GOOS=windows GOARCH=amd64 go build -o builds/tiny-requestbin-${{ env.TAG }}-windows-amd64.exe .
49+
50+
# 创建压缩文件
51+
cd builds
52+
53+
# 压缩Mac二进制文件
54+
tar -czf tiny-requestbin-${{ env.TAG }}-darwin-amd64.tar.gz tiny-requestbin-${{ env.TAG }}-darwin-amd64
55+
tar -czf tiny-requestbin-${{ env.TAG }}-darwin-arm64.tar.gz tiny-requestbin-${{ env.TAG }}-darwin-arm64
56+
57+
# 压缩Linux二进制文件
58+
tar -czf tiny-requestbin-${{ env.TAG }}-linux-amd64.tar.gz tiny-requestbin-${{ env.TAG }}-linux-amd64
59+
tar -czf tiny-requestbin-${{ env.TAG }}-linux-arm64.tar.gz tiny-requestbin-${{ env.TAG }}-linux-arm64
60+
61+
# 压缩Windows二进制文件
62+
zip tiny-requestbin-${{ env.TAG }}-windows-amd64.zip tiny-requestbin-${{ env.TAG }}-windows-amd64.exe
63+
64+
- name: Create Release
65+
id: create_release
66+
uses: softprops/action-gh-release@v1
67+
with:
68+
name: Release ${{ env.TAG }}
69+
draft: false
70+
prerelease: false
71+
files: |
72+
builds/tiny-requestbin-${{ env.TAG }}-darwin-amd64.tar.gz
73+
builds/tiny-requestbin-${{ env.TAG }}-darwin-arm64.tar.gz
74+
builds/tiny-requestbin-${{ env.TAG }}-linux-amd64.tar.gz
75+
builds/tiny-requestbin-${{ env.TAG }}-linux-arm64.tar.gz
76+
builds/tiny-requestbin-${{ env.TAG }}-windows-amd64.zip

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type PageData struct {
3838
SelectedRequest *RequestInfo // Using a pointer so that it can be nil when no request is selected
3939
}
4040

41+
// Version information will be set during build
42+
var Version = "dev"
43+
4144
// Global store for our requests
4245
// We use global variables to store requests.
4346
var (

0 commit comments

Comments
 (0)