Files
HxClaw/.gitea/workflows/release.yml
titor 68d4a9530c
Some checks failed
Release / build (push) Has been cancelled
fix: 添加 alpine 国内镜像源
2026-04-27 06:21:42 +08:00

66 lines
2.2 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.26-alpine
env:
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
steps:
- name: Setup mirrors
run: |
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
- name: Checkout
run: |
apk add git bash
rm -rf /workspace/hxclaw/hxclaw 2>/dev/null || true
git clone https://hub.gaomia.site/titor/hxclaw.git /workspace/hxclaw/hxclaw
cd /workspace/hxclaw/hxclaw
- name: Download dependencies
run: cd /workspace/hxclaw && go mod download
- name: Build
run: |
cd /workspace/hxclaw
for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
os=${p%/*}
arch=${p#*/}
ext=""
[ "$os" = "windows" ] && ext=".exe"
GOOS=$os GOARCH=$arch go build -o "hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
done
- name: Checksums
run: cd /workspace/hxclaw && sha256sum hxclaw-* > checksums.txt
- name: Release
env:
GITEA_TOKEN: "${{ secrets.release_token }}"
run: |
cd /workspace/hxclaw
apk add curl jq
TAG_NAME="${GITHUB_REF#refs/tags/}"
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" \
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${RELEASE_BODY}\"}")
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
for f in hxclaw-* checksums.txt; do
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@$f"
done