**feat(ci):** enhance release workflow with changelog generation and detailed release body
All checks were successful
CI / build-test (push) Successful in 1m2s
All checks were successful
CI / build-test (push) Successful in 1m2s
- Add `jq` dependency for JSON manipulation - Automatically generate changelog from Git history for releases - Refactor release body to include Docker image details and formatted changelog Changelog: other
This commit is contained in:
@@ -50,7 +50,7 @@ jobs:
|
||||
DOCKER_HOST: tcp://dind:2375
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: apk add --no-cache git curl
|
||||
run: apk add --no-cache git curl jq
|
||||
|
||||
- name: Checkout with full history
|
||||
run: |
|
||||
@@ -106,8 +106,25 @@ jobs:
|
||||
|
||||
- name: Create Gitea release
|
||||
run: |
|
||||
REGISTRY="${{ gitea.server_url }}"
|
||||
REGISTRY="${REGISTRY#https://}"
|
||||
REGISTRY="${REGISTRY#http://}"
|
||||
IMAGE="$REGISTRY/$(echo '${{ gitea.repository }}' | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
PREV_TAG=$(git tag --sort=-version:refname | { grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true; } | sed -n '2p')
|
||||
if [ -n "$PREV_TAG" ]; then
|
||||
CHANGELOG=$(git log --pretty=format:"- %s" "${PREV_TAG}..HEAD")
|
||||
else
|
||||
CHANGELOG=$(git log --pretty=format:"- %s")
|
||||
fi
|
||||
|
||||
BODY=$(printf '## Docker Image\n```\ndocker pull %s:%s\n```\n\n## Changelog\n%s' "$IMAGE" "$NEW_VERSION" "$CHANGELOG")
|
||||
|
||||
jq -n --arg tag "$NEW_VERSION" --arg name "$NEW_VERSION" --arg body "$BODY" \
|
||||
'{tag_name: $tag, name: $name, body: $body}' > /tmp/release.json
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||
-d "{\"tag_name\": \"$NEW_VERSION\", \"name\": \"$NEW_VERSION\", \"generate_release_notes\": true}"
|
||||
-d @/tmp/release.json
|
||||
|
||||
Reference in New Issue
Block a user