diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 6c53879..cbbe11c 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -7,55 +7,82 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: local 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 + - name: Checkout code run: | - apk add git bash - rm -rf /workspace - git clone https://hub.gaomia.site/titor/hxclaw.git /workspace + apk add git curl - name: Download dependencies - run: cd /workspace && go mod download + run: go mod download - - name: Build + - name: Build for all platforms run: | - cd /workspace - for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do - os=${p%/*} - arch=${p#*/} + mkdir -p dist + + platforms=( + "linux/amd64" + "linux/arm64" + "darwin/amd64" + "darwin/arm64" + "windows/amd64" + ) + + for p in "${platforms[@]}"; do + os="${p%/*}" + arch="${p#*/}" ext="" [ "$os" = "windows" ] && ext=".exe" - GOOS=$os GOARCH=$arch go build -o "hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw + output="dist/hxclaw-${os}-${arch}${ext}" + GOOS=$os GOARCH=$arch go build -o "$output" ./cmd/hxclaw + echo "Built: $output" done - - name: Checksums - run: cd /workspace && sha256sum hxclaw-* > checksums.txt - - - name: Release - env: - GITEA_TOKEN: "${{ secrets.release_token }}" + - name: Generate checksums run: | - cd /workspace - 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}\"}") - + cd dist + sha256sum hxclaw-* > checksums.txt + cat checksums.txt + + - name: Create release and upload assets + run: | + TAG_NAME="${GITEA_REF#refs/tags/}" + + RELEASE_BODY=$(git log --format="%s%n%b" "$TAG_NAME" -1 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" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$TAG_NAME\", + \"name\": \"$TAG_NAME\", + \"body\": \"$RELEASE_BODY\", + \"draft\": false, + \"prerelease\": false + }" + ) + 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 \ No newline at end of file + + 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" \ + -F "attachment=@$f" + echo "Uploaded: $f" + fi + done + + echo "Release completed!" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9688c9b..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,57 +0,0 @@ -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: Checkout - run: | - apk add git bash - - - name: Download dependencies - run: go mod download - - - name: Build - run: | - 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: sha256sum hxclaw-* > checksums.txt - - - name: Release - env: - GITEA_TOKEN: ${{ secrets.release_token }} - run: | - 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 \ No newline at end of file diff --git a/changelog.md b/changelog.md index 5ce67cb..482a4af 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,7 @@ ## 版本记录 -### v0.1.0 +### v0.1.0 (当前) - [x] 流式输出功能 - [x] Markdown 渲染功能