Skip to content

Commit 0ba0c45

Browse files
committed
chore: fix release.yml
1 parent e6f4e18 commit 0ba0c45

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
# Checkout the code
1111
- name: Checkout code
1212
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0 # Fetch all history for all branches and tags
1315

1416
# Set up Node.js
1517
- name: Set up Node.js
@@ -21,23 +23,34 @@ jobs:
2123
- name: Install dependencies
2224
run: npm install
2325

26+
# Set up Git username and email
27+
- name: Set Git user name and email
28+
run: |
29+
git config --global user.name "GitHub Actions"
30+
git config --global user.email "actions@github.com"
31+
2432
# Bump version and generate changelog
2533
- name: Bump version and generate changelog
2634
run: npx standard-version
27-
35+
2836
# Extract release notes for the current version from CHANGELOG.md
2937
- name: Extract release notes
3038
id: release-notes
3139
run: |
3240
VERSION=$(node -p "require('./package.json').version")
33-
RELEASE_NOTES=$(awk "/## $VERSION /{flag=1; next} /## [0-9]/{flag=0} flag" CHANGELOG.md)
34-
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_ENV
41+
echo "VERSION=$VERSION" >> $GITHUB_ENV
42+
RELEASE_NOTES=$(awk -v version="$VERSION" '$0 ~ "## \\[" version "\\]" {flag=1; next} $0 ~ "## \\[[0-9]+\\.[0-9]+\\.[0-9]+\\]" {flag=0} flag' CHANGELOG.md)
43+
echo "$VERSION"
44+
echo "$RELEASE_NOTES"
45+
{
46+
echo "RELEASE_NOTES<<EOF"
47+
echo "$RELEASE_NOTES"
48+
echo "EOF"
49+
} >> $GITHUB_ENV
3550
3651
# Push changes (version bump and tag) to the repository
3752
- name: Push changes
3853
run: |
39-
git config --global user.name "GitHub Actions"
40-
git config --global user.email "actions@github.com"
4154
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
4255
git push --follow-tags origin master
4356
@@ -50,6 +63,7 @@ jobs:
5063
uses: softprops/action-gh-release@v1
5164
with:
5265
files: dist/*
66+
tag_name: v${{ env.VERSION }}
5367
body: ${{ env.RELEASE_NOTES }} # Use the extracted release notes
5468
env:
5569
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)