Skip to content

fix: 更新配置文件 #10

fix: 更新配置文件

fix: 更新配置文件 #10

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:
build:
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
# Trim trailing newlines
FEAT="${FEAT%%$(printf '\n')}"
FIX="${FIX%%$(printf '\n')}"
DOCS="${DOCS%%$(printf '\n')}"
OTHER="${OTHER%%$(printf '\n')}"
# 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 }}
body: |
$(if [[ "${{ steps.changelog.outputs.feat }}" != "" ]]; then echo "**Features**:\n${{ steps.changelog.outputs.feat }}\n\n"; fi)
$(if [[ "${{ steps.changelog.outputs.fix }}" != "" ]]; then echo "**Fixes**:\n${{ steps.changelog.outputs.fix }}\n\n"; fi)
$(if [[ "${{ steps.changelog.outputs.docs }}" != "" ]]; then echo "**Docs**:\n${{ steps.changelog.outputs.docs }}\n\n"; fi)
$(if [[ "${{ steps.changelog.outputs.other }}" != "" ]]; then echo "**Other**:\n${{ steps.changelog.outputs.other }}\n\n"; fi)
draft: false
prerelease: false