Compare commits
2 Commits
003815239d
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e5b878a9c | |||
| 90320808e4 |
56
.gitea/workflows/release.yaml
Normal file
56
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: hub.gaomia.site/titor/bun:latest
|
||||
steps:
|
||||
- name: Install git
|
||||
run: apt-get update && apt-get install -y git
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone https://${{ secrets.release_token }}@hub.gaomia.site/titor/mio.git /workspace/mio
|
||||
cd /workspace/mio
|
||||
|
||||
- name: Create source archive
|
||||
run: |
|
||||
git archive --format=zip -o mio-source.zip HEAD
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.release_token }}
|
||||
run: |
|
||||
cd /workspace/mio
|
||||
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
|
||||
if [ -n "$PREV_TAG" ]; then
|
||||
CHANGES=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG..HEAD" 2>/dev/null || echo "")
|
||||
else
|
||||
CHANGES=$(git log --pretty=format:"- %s (%h)" -n 20 2>/dev/null || echo "")
|
||||
fi
|
||||
|
||||
if [ -n "$CHANGES" ]; then
|
||||
RELEASE_BODY="## Changes\n\n$CHANGES"
|
||||
else
|
||||
RELEASE_BODY="Release $TAG_NAME"
|
||||
fi
|
||||
|
||||
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)
|
||||
|
||||
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/mio/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@mio-source.zip"
|
||||
Reference in New Issue
Block a user