Skip to content

Commit

Permalink
ci: 新增自动构建
Browse files Browse the repository at this point in the history
  • Loading branch information
SugarMGP committed Dec 6, 2024
1 parent 53235cd commit 7f36005
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22

- name: Build
run: |
go install src.techknowlogick.com/xgo@latest
xgo -out 4uonline --targets=*/amd64 .
- name: Archive Output
run: |
mkdir -p artifacts
mv 4uonline* artifacts/
cp README.md artifacts/
cp config.example.yaml artifacts/config.yaml
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: artifacts/
12 changes: 1 addition & 11 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# 设置环境变量
CGO_ENABLED=0
GOOS=linux
GOARCH=amd64

# Go 文件
TARGET=main

Expand All @@ -14,11 +9,6 @@ build:
@echo "Building $(TARGET)..."
go build -o $(TARGET) $(TARGET).go

# 编译为 Linux 目标
build-linux:
@echo "Building $(TARGET) for $(GOOS)/$(GOARCH)..."
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=$(CGO_ENABLED) go build -o $(TARGET) $(TARGET).go

# 清理生成的文件
clean:
@echo "Cleaning up..."
Expand All @@ -27,4 +17,4 @@ clean:
# 运行程序
run: build
@echo "Running $(TARGET)..."
./$(TARGET)
./$(TARGET)

0 comments on commit 7f36005

Please sign in to comment.