Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
nowscott committed Jul 19, 2024
1 parent 0e4bf65 commit 6fcc200
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 0 # 确保拉取所有历史记录和标签

- name: Get latest release tag
id: get_latest_release
Expand Down Expand Up @@ -43,15 +43,13 @@ jobs:
echo "RELEASE=false" >> $GITHUB_ENV
fi
- name: Generate GitHub Style Release Notes
- name: Generate Release Notes
if: env.RELEASE == 'true'
id: generate_release_notes
run: |
RELEASE_NOTES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/generate_notes \
-d "{\"tag_name\":\"v${{ env.PACKAGE_VERSION }}\",\"previous_tag_name\":\"${{ env.PREVIOUS_TAG }}\"}" \
| jq -r '.body')
git fetch --tags
# 获取提交信息并格式化
RELEASE_NOTES=$(git log ${{ env.PREVIOUS_TAG }}..HEAD --pretty=format:"* %s by @%an in %h" --abbrev-commit)
# 处理日志换行符
RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
Expand All @@ -64,14 +62,6 @@ jobs:
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Delete existing tag if exists
if: env.RELEASE == 'true'
run: |
if git rev-parse "v${{ env.PACKAGE_VERSION }}" >/dev/null 2>&1; then
git tag -d "v${{ env.PACKAGE_VERSION }}"
git push --delete origin "v${{ env.PACKAGE_VERSION }}"
fi
- name: Add package.json and commit changes
if: env.RELEASE == 'true'
run: |
Expand All @@ -94,4 +84,6 @@ jobs:
with:
tag_name: v${{ env.PACKAGE_VERSION }}
release_name: Release ${{ env.PACKAGE_VERSION }}
body: ${{ env.RELEASE_NOTES }}
body: |
### 更新日志
${{ env.RELEASE_NOTES }}

0 comments on commit 6fcc200

Please sign in to comment.