Skip to content

Commit

Permalink
fix: 测试actions 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Aug 3, 2024
1 parent 42569b6 commit cb90f5c
Showing 1 changed file with 17 additions and 31 deletions.
48 changes: 17 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
fetch-depth: 0

- name: Get last tag
id: last_tag
Expand All @@ -24,32 +24,13 @@ jobs:
- name: Generate changelog
id: changelog
run: |
# Initialize changelog variables
FEAT=""
FIX=""
DOCS=""
OTHER=""
# Generate changelog by parsing commit messages and set as output variables
FEAT=$(git log ${{ steps.last_tag.outputs.tag }}..HEAD --grep="feat:" --pretty=format:"- %s" | sed 's/feat: //' | tr '\n' ' ')
FIX=$(git log ${{ steps.last_tag.outputs.tag }}..HEAD --grep="fix:" --pretty=format:"- %s" | sed 's/fix: //' | tr '\n' ' ')
DOCS=$(git log ${{ steps.last_tag.outputs.tag }}..HEAD --grep="docs:" --pretty=format:"- %s" | sed 's/docs: //' | tr '\n' ' ')
OTHER=$(git log ${{ steps.last_tag.outputs.tag }}..HEAD --grep -vE "feat:|fix:|docs:" --pretty=format:"- %s" | tr '\n' ' ')
# 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
# Set output variables
echo "::set-output name=feat::$FEAT"
echo "::set-output name=fix::$FIX"
echo "::set-output name=docs::$DOCS"
Expand All @@ -59,14 +40,19 @@ jobs:
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FEAT: ${{ steps.changelog.outputs.feat }}
FIX: ${{ steps.changelog.outputs.fix }}
DOCS: ${{ steps.changelog.outputs.docs }}
OTHER: ${{ steps.changelog.outputs.other }}
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)
${{ fromJson('{"feat":env.FEAT,"fix":env.FIX,"docs":env.DOCS,"other":env.OTHER}') }}
${{ if env.FEAT != '' }}**Features**:\n${{ env.FEAT }}\n\n{{ end }}
${{ if env.FIX != '' }}**Fixes**:\n${{ env.FIX }}\n\n{{ end }}
${{ if env.DOCS != '' }}**Docs**:\n${{ env.DOCS }}\n\n{{ end }}
${{ if env.OTHER != '' }}**Other**:\n${{ env.OTHER }}\n\n{{ end }}
draft: false
prerelease: false

0 comments on commit cb90f5c

Please sign in to comment.