ci: add Gitea release workflow on tag push
Creates an automated Gitea release with changelog when a tag (v*) is pushed. Requires GITEA_TOKEN secret in Gitea with repository write access.
This commit is contained in:
1 parent
c8ccbe1f42
commit
9b8a0e5075
1 file changed
+66
@@ -0,0 +1,66 @@
|
||||
name: Create Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
jobs:
|
||||
release:
|
||||
runs-on: shell
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
git fetch origin --prune --tags
|
||||
git checkout -f "${{ gitea.ref_name }}"
|
||||
|
||||
- name: Generate Release Notes
|
||||
id: notes
|
||||
run: |
|
||||
PREV_TAG="$(git tag --sort=-creatordate | head -2 | tail -1 || echo '')"
|
||||
if [ -n "$PREV_TAG" ]; then
|
||||
RANGE="${PREV_TAG}..${{ gitea.ref_name }}"
|
||||
NOTES="$(git log --oneline --no-decorate "${RANGE}" 2>/dev/null || git log --oneline --no-decorate -20)"
|
||||
else
|
||||
NOTES="$(git log --oneline --no-decorate -30)"
|
||||
fi
|
||||
echo "NOTES<<EOF" >> "$GITHUB_ENV"
|
||||
echo "$NOTES" >> "$GITHUB_ENV"
|
||||
echo "EOF" >> "$GITHUB_ENV"
|
||||
|
||||
echo "VERSION=${{ gitea.ref_name }}" >> "$GITHUB_ENV"
|
||||
|
||||
echo "=== Release Notes ==="
|
||||
echo "$NOTES"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd /var/www/atom-nexst/
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm prisma:generate
|
||||
export SKIP_ENV_VALIDATION=1
|
||||
pnpm build
|
||||
|
||||
- name: Create Release
|
||||
run: |
|
||||
# Use the Gitea API to create a release
|
||||
BODY="## EpicNext-CMS ${{ env.VERSION }}
|
||||
|
||||
### Changes
|
||||
${{ env.NOTES }}
|
||||
|
||||
---
|
||||
_Automated release from Gitea Actions_
|
||||
"
|
||||
|
||||
curl -s -X POST "${{ gitea.api_url }}/repos/${{ gitea.repository }}/releases" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(cat <<-ENDJSON
|
||||
{
|
||||
"tag_name": "${{ env.VERSION }}",
|
||||
"name": "${{ env.VERSION }}",
|
||||
"body": $(echo "$BODY" | jq -Rs '.'),
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
ENDJSON
|
||||
)"
|
||||
Reference in new issue
Block a user