fix: 简化 workflow
This commit is contained in:
@@ -5,57 +5,40 @@ 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
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: apt-get update && apt-get install -y git curl go
|
||||||
apt-get update && apt-get install -y git curl go
|
|
||||||
|
|
||||||
- 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
|
mkdir -p dist
|
||||||
platforms="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64"
|
GOOS=linux GOARCH=amd64 go build -o dist/hxclaw-linux-amd64 ./cmd/hxclaw
|
||||||
for p in $platforms; do
|
GOOS=linux GOARCH=arm64 go build -o dist/hxclaw-linux-arm64 ./cmd/hxclaw
|
||||||
os=$(echo "$p" | cut -d/ -f1)
|
GOOS=darwin GOARCH=amd64 go build -o dist/hxclaw-darwin-amd64 ./cmd/hxclaw
|
||||||
arch=$(echo "$p" | cut -d/ -f2)
|
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
|
||||||
if [ "$os" = "windows" ]; then
|
|
||||||
ext=".exe"
|
|
||||||
fi
|
|
||||||
GOOS=$os GOARCH=$arch go build -o "dist/hxclaw-${os}-${arch}${ext}" ./cmd/hxclaw
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Generate checksums
|
- name: Checksum
|
||||||
run: |
|
run: cd dist && sha256sum hxclaw-* > checksums.txt
|
||||||
cd dist
|
|
||||||
sha256sum hxclaw-* > checksums.txt
|
|
||||||
cat checksums.txt
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
run: |
|
run: |
|
||||||
TAG_NAME="${GITEA_REF#refs/tags/}"
|
TAG_NAME="${GITEA_REF#refs/tags/}"
|
||||||
echo "Creating release: $TAG_NAME"
|
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases" \
|
||||||
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases" \
|
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.RELEASE_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 $TAG_NAME\"}"
|
||||||
|
|
||||||
- name: Upload assets
|
- name: Upload
|
||||||
run: |
|
run: |
|
||||||
for f in dist/hxclaw-* dist/checksums.txt; do
|
for f in dist/hxclaw-* dist/checksums.txt; do
|
||||||
if [ -f "$f" ]; then
|
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/hxclaw/releases/latest/assets" \
|
||||||
curl -s -X POST "$GITEA_URL/api/v1/repos/titor/hxclaw/releases/latest/assets" \
|
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
-F "attachment=@$f"
|
-F "attachment=@$f"
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "Release completed!"
|
|
||||||
Reference in New Issue
Block a user