Skip to content

fix: 更新模板

fix: 更新模板 #9

Workflow file for this run

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Release
permissions: write-all
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Get last tag
id: last_tag
run: |
echo "::set-output name=tag::$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1))"
- name: Generate changelog
id: changelog
run: |
# Initialize changelog variables
FEAT=""
FIX=""
DOCS=""
OTHER=""
# Generate changelog by parsing commit messages
git log ${{ steps.last_tag.outputs.tag }}..HEAD --pretty=format:"%s" | while read line; do
if [[ $line == feat:* ]]; then
FEAT="${FEAT}- ${line#feat: }\n"
elif [[ $line == fix:* ]]; then
FIX="${FIX}- ${line#fix: }\n"
elif [[ $line == docs:* ]]; then
DOCS="${DOCS}- ${line#docs: }\n"
else
OTHER="${OTHER}- $line\n"
fi
done
# Set changelog outputs
echo "::set-output name=feat::$FEAT"
echo "::set-output name=fix::$FIX"
echo "::set-output name=docs::$DOCS"
echo "::set-output name=other::$OTHER"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: |
**Features**:
${{ steps.changelog.outputs.feat }}
**Fixes**:
${{ steps.changelog.outputs.fix }}
**Documentation**:
${{ steps.changelog.outputs.docs }}
**Other**:
${{ steps.changelog.outputs.other }}