2 Commits

Author SHA1 Message Date
d27771e020 fix: 按照示例修改 workflow 格式
Some checks failed
Release / build (push) Has been cancelled
2026-04-23 21:15:10 +08:00
efa10cb0e6 fix: 简化 workflow 2026-04-23 21:12:54 +08:00

View File

@@ -5,57 +5,57 @@ on:
tags: tags:
- 'v*' - 'v*'
env:
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
GITEA_URL: "https://hub.gaomia.site"
jobs: jobs:
build: build:
runs-on: ubuntu runs-on: ubuntu-latest
container:
image: golang:1.26-alpine
env:
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
steps: steps:
- name: Checkout code - name: Checkout
run: | run: |
apt-get update && apt-get install -y git curl go apk add git bash
git clone https://hub.gaomia.site/titor/HxClaw.git /workspace/hxclaw
cp -r /workspace/hxclaw/* /workspace/hxclaw/
cp -r /workspace/hxclaw/.* /workspace/hxclaw/ 2>/dev/null || true
- name: Download dependencies - name: Download dependencies
run: go mod download run: go mod download
- name: Build for all platforms - name: Build
run: | run: |
mkdir -p dist cd /workspace/hxclaw
platforms="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64" for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
for p in $platforms; do os=${p%/*}
os=$(echo "$p" | cut -d/ -f1) arch=${p#*/}
arch=$(echo "$p" | cut -d/ -f2)
ext="" ext=""
if [ "$os" = "windows" ]; then [ "$os" = "windows" ] && ext=".exe"
ext=".exe" GOOS=$os GOARCH=$arch go build -o "hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
fi
GOOS=$os GOARCH=$arch go build -o "dist/hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
done done
- name: Generate checksums - name: Checksums
run: | run: sha256sum hxclaw-* > checksums.txt
cd dist
sha256sum hxclaw-* > checksums.txt
cat checksums.txt
- name: Create release - name: Release
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: | run: |
TAG_NAME="${GITEA_REF#refs/tags/}" apk add curl jq
echo "Creating release: $TAG_NAME"
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases" \ TAG_NAME="${GITHUB_REF#refs/tags/}"
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
RELEASE_BODY=$(git tag -l --format='%(contents)' "$TAG_NAME" 2>/dev/null || git log -1 --format="%s%n%n%b" "$TAG_NAME" 2>/dev/null || echo "Release $TAG_NAME")
RELEASE_RESPONSE=$(curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG_NAME\",\"name\":\"$TAG_NAME\",\"body\":\"Release $TAG_NAME\"}" -d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${RELEASE_BODY}\"}")
- name: Upload assets RELEASE_ID=$(echo "$RELEASE_RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
run: |
for f in dist/hxclaw-* dist/checksums.txt; do for f in hxclaw-* checksums.txt; do
if [ -f "$f" ]; then [ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases/${RELEASE_ID}/assets" \
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases/latest/assets" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -F "attachment=@$f"
-F "attachment=@$f"
fi
done done
echo "Release completed!"