@@ -16,28 +16,28 @@ jobs:
16
16
- name : Checkout repository
17
17
uses : actions/checkout@v4
18
18
19
- - name : Get latest and previous release tags
19
+ - name : Get latest release tags
20
20
id : get_releases
21
21
run : |
22
- LATEST_RELEASE=$(gh release list --limit 2 --json tagName --jq '.[0].tagName')
23
- PREV_RELEASE =$(gh release list --limit 2 -- json tagName --jq '.[1 ].tagName')
24
-
22
+ # Fetch the latest release that is not a draft
23
+ LATEST_RELEASE =$(gh release list --json tagName,isDraft --jq '[.[] | select(.isDraft == false)] | .[0 ].tagName')
24
+
25
25
echo "Latest release: $LATEST_RELEASE"
26
- echo "Previous release: $PREV_RELEASE"
27
26
27
+ # Set the latest release tag as an environment variable
28
28
echo "LATEST_RELEASE=$LATEST_RELEASE" >> "$GITHUB_ENV"
29
- echo "PREV_RELEASE=$PREV_RELEASE" >> "$GITHUB_ENV"
30
29
env :
31
30
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
31
33
- - name : Get previous release notes
32
+ - name : Get release notes for the latest release
34
33
id : fetch_release_notes
35
34
run : |
36
- gh release view "$PREV_RELEASE" --json body --jq '.body' > release_notes.txt
35
+ # Fetch the release notes of the latest release
36
+ gh release view "$LATEST_RELEASE" --json body --jq '.body' > release_notes.txt
37
37
env :
38
38
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39
39
40
- - name : Display current release notes
40
+ - name : Display current release notes before modification
41
41
run : |
42
42
echo "Current release notes before modification:"
43
43
cat release_notes.txt
@@ -48,11 +48,11 @@ jobs:
48
48
echo "Checking if the badges section is being matched:"
49
49
head -n 5 release_notes.txt # Show first few lines of the release notes
50
50
51
- # Match the top badge section and replace it
51
+ # Define the badge regex and new badges content
52
52
BADGE_REGEX='!\[Version\].*!\[Tag\].*\n'
53
53
54
- # Define new badges with updated links for latest release
55
- NEW_BADGES="   \n"
54
+ # New badges content with updated links for latest release
55
+ NEW_BADGES="   \n"
56
56
57
57
# Use sed to replace only the badge section at the top of the release notes
58
58
sed -i -E "0,/$BADGE_REGEX/s|$BADGE_REGEX|$NEW_BADGES|" release_notes.txt
61
61
echo "Modified release notes:"
62
62
head -n 10 release_notes.txt # Show the modified section
63
63
64
- - name : Update previous release with modified notes
64
+ - name : Update latest release with modified notes
65
65
run : |
66
- gh release edit "$PREV_RELEASE" --notes-file release_notes.txt
66
+ # Update the release notes of the latest release
67
+ gh release edit "$LATEST_RELEASE" --notes-file release_notes.txt
67
68
env :
68
69
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments