Compare commits
17 Commits
v0.1.0-tes
...
v0.2.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c6bbe04f1 | |||
| c7767edd4f | |||
| cc9b2a5c76 | |||
| d27771e020 | |||
| efa10cb0e6 | |||
| 1da98957c2 | |||
| bd48c305ab | |||
| 9653260567 | |||
| 6595a39abe | |||
| 5fd58e44bb | |||
| 38b957d40b | |||
| 85e710ea02 | |||
| 3d9b2d6a90 | |||
| 0427274994 | |||
| c79977496d | |||
| b8d0530118 | |||
| e0b7ea984f |
@@ -7,82 +7,59 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: local
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: golang:1.26-alpine
|
||||
env:
|
||||
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
|
||||
GITEA_URL: "https://hub.gaomia.site"
|
||||
GITEA_TOKEN: "${{ secrets.release_token }}"
|
||||
steps:
|
||||
- name: Checkout code
|
||||
- name: Checkout
|
||||
run: |
|
||||
apk add git curl
|
||||
# 使用阿里云 apk 镜像源
|
||||
echo -e 'https://mirrors.aliyun.com/alpine/v3.20/main/\nhttps://mirrors.aliyun.com/alpine/v3.20/community/' > /etc/apk/repositories
|
||||
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
|
||||
run: go mod download
|
||||
|
||||
- name: Build for all platforms
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir -p dist
|
||||
|
||||
platforms=(
|
||||
"linux/amd64"
|
||||
"linux/arm64"
|
||||
"darwin/amd64"
|
||||
"darwin/arm64"
|
||||
"windows/amd64"
|
||||
)
|
||||
|
||||
for p in "${platforms[@]}"; do
|
||||
os="${p%/*}"
|
||||
arch="${p#*/}"
|
||||
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"
|
||||
output="dist/hxclaw-${os}-${arch}${ext}"
|
||||
GOOS=$os GOARCH=$arch go build -o "$output" ./cmd/hxclaw
|
||||
echo "Built: $output"
|
||||
GOOS=$os GOARCH=$arch go build -o "hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
|
||||
done
|
||||
|
||||
- name: Generate checksums
|
||||
- name: Checksums
|
||||
run: sha256sum hxclaw-* > checksums.txt
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
cd dist
|
||||
sha256sum hxclaw-* > checksums.txt
|
||||
cat checksums.txt
|
||||
# 使用阿里云 apk 镜像源
|
||||
echo -e 'https://mirrors.aliyun.com/alpine/v3.20/main/\nhttps://mirrors.aliyun.com/alpine/v3.20/community/' > /etc/apk/repositories
|
||||
apk add curl jq
|
||||
|
||||
- name: Create release and upload assets
|
||||
run: |
|
||||
TAG_NAME="${GITEA_REF#refs/tags/}"
|
||||
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
RELEASE_BODY=$(git log --format="%s%n%b" "$TAG_NAME" -1 2>/dev/null || echo "Release $TAG_NAME")
|
||||
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")
|
||||
|
||||
echo "Creating release: $TAG_NAME"
|
||||
|
||||
RELEASE_RESPONSE=$(
|
||||
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
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\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": false
|
||||
}"
|
||||
)
|
||||
-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)
|
||||
|
||||
echo "Release ID: $RELEASE_ID"
|
||||
|
||||
for f in dist/hxclaw-* dist/checksums.txt; do
|
||||
if [ -f "$f" ]; then
|
||||
echo "Uploading: $f"
|
||||
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
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"
|
||||
echo "Uploaded: $f"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Release completed!"
|
||||
Reference in New Issue
Block a user