Feature:
增加Gitea自动发布二进制版本
This commit is contained in:
50
.gitea/workflows/release.yaml
Normal file
50
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: hub.gaomia.site/titor/bun:latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone https://${{ secrets.release_token }}@hub.gaomia.site/titor/mio.git /workspace/mio
|
||||
cd /workspace/mio
|
||||
cp -r /workspace/mio/* /workspace/ || true
|
||||
cp -r /workspace/mio/.* /workspace/ 2>/dev/null || true
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd /workspace
|
||||
bun install
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd /workspace
|
||||
bun run build
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.release_token }}
|
||||
run: |
|
||||
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
RELEASE_BODY=$(git tag -l --format='%(contents)' "$TAG_NAME" 2>/dev/null || echo "Release $TAG_NAME")
|
||||
|
||||
RELEASE_RESPONSE=$(curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/mio/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 mio.exe; do
|
||||
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/mio/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@$f"
|
||||
done
|
||||
Reference in New Issue
Block a user