chore: add release workflow with auto changelog
Some checks failed
Release / build (push) Failing after 2m24s
Some checks failed
Release / build (push) Failing after 2m24s
This commit is contained in:
@@ -11,30 +11,38 @@ jobs:
|
||||
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
|
||||
cp -r /workspace/mio/* /workspace/ || true
|
||||
cp -r /workspace/mio/.* /workspace/ 2>/dev/null || true
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Create source archive
|
||||
run: |
|
||||
cd /workspace
|
||||
bun install
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd /workspace
|
||||
bun run build
|
||||
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/}"
|
||||
|
||||
RELEASE_BODY=$(git tag -l --format='%(contents)' "$TAG_NAME" 2>/dev/null || echo "Release $TAG_NAME")
|
||||
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}" \
|
||||
@@ -43,8 +51,6 @@ jobs:
|
||||
|
||||
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
|
||||
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