This commit is contained in:
@@ -7,38 +7,55 @@ on:
|
|||||||
|
|
||||||
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: apt-get update && apt-get install -y git curl go
|
run: |
|
||||||
|
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
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist
|
cd /workspace/hxclaw
|
||||||
GOOS=linux GOARCH=amd64 go build -o dist/hxclaw-linux-amd64 ./cmd/hxclaw
|
for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
|
||||||
GOOS=linux GOARCH=arm64 go build -o dist/hxclaw-linux-arm64 ./cmd/hxclaw
|
os=${p%/*}
|
||||||
GOOS=darwin GOARCH=amd64 go build -o dist/hxclaw-darwin-amd64 ./cmd/hxclaw
|
arch=${p#*/}
|
||||||
GOOS=darwin GOARCH=arm64 go build -o dist/hxclaw-darwin-arm64 ./cmd/hxclaw
|
ext=""
|
||||||
GOOS=windows GOARCH=amd64 go build -o dist/hxclaw-windows-amd64.exe ./cmd/hxclaw
|
[ "$os" = "windows" ] && ext=".exe"
|
||||||
|
GOOS=$os GOARCH=$arch go build -o "hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
|
||||||
|
done
|
||||||
|
|
||||||
- name: Checksum
|
- name: Checksums
|
||||||
run: cd dist && sha256sum hxclaw-* > checksums.txt
|
run: sha256sum hxclaw-* > 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
|
||||||
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases" \
|
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
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" \
|
-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
|
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
|
||||||
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases/latest/assets" \
|
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases/${RELEASE_ID}/assets" \
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-F "attachment=@$f"
|
-F "attachment=@$f"
|
||||||
done
|
done
|
||||||
Reference in New Issue
Block a user