Skip to content

Commit b64f4d5

Browse files
authored
Update update-release.yml
1 parent 03b5d85 commit b64f4d5

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

.github/workflows/update-release.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19-
- name: Get latest and previous release tags
19+
- name: Get latest release tags
2020
id: get_releases
2121
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+
2525
echo "Latest release: $LATEST_RELEASE"
26-
echo "Previous release: $PREV_RELEASE"
2726
27+
# Set the latest release tag as an environment variable
2828
echo "LATEST_RELEASE=$LATEST_RELEASE" >> "$GITHUB_ENV"
29-
echo "PREV_RELEASE=$PREV_RELEASE" >> "$GITHUB_ENV"
3029
env:
3130
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3231

33-
- name: Get previous release notes
32+
- name: Get release notes for the latest release
3433
id: fetch_release_notes
3534
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
3737
env:
3838
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939

40-
- name: Display current release notes
40+
- name: Display current release notes before modification
4141
run: |
4242
echo "Current release notes before modification:"
4343
cat release_notes.txt
@@ -48,11 +48,11 @@ jobs:
4848
echo "Checking if the badges section is being matched:"
4949
head -n 5 release_notes.txt # Show first few lines of the release notes
5050
51-
# Match the top badge section and replace it
51+
# Define the badge regex and new badges content
5252
BADGE_REGEX='!\[Version\].*!\[Tag\].*\n'
5353
54-
# Define new badges with updated links for latest release
55-
NEW_BADGES="![GitHub release (latest by hari)](https://img.shields.io/github/downloads/harilvfs/carch/$PREV_RELEASE/total?color=%235E81AC&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/harilvfs/carch/$PREV_RELEASE?color=%23A3BE8C&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![GitHub release date](https://img.shields.io/github/release-date/harilvfs/carch?color=%23F28FAD&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![Tag](https://img.shields.io/github/v/tag/harilvfs/carch?color=%23E06C75&style=for-the-badge&logoColor=85e185&labelColor=1c1c29)\n"
54+
# New badges content with updated links for latest release
55+
NEW_BADGES="![GitHub release (latest by hari)](https://img.shields.io/github/downloads/harilvfs/carch/$LATEST_RELEASE/total?color=%235E81AC&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/harilvfs/carch/$LATEST_RELEASE?color=%23A3BE8C&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![GitHub release date](https://img.shields.io/github/release-date/harilvfs/carch?color=%23F28FAD&style=for-the-badge&logoColor=85e185&labelColor=1c1c29) ![Tag](https://img.shields.io/github/v/tag/harilvfs/carch?color=%23E06C75&style=for-the-badge&logoColor=85e185&labelColor=1c1c29)\n"
5656
5757
# Use sed to replace only the badge section at the top of the release notes
5858
sed -i -E "0,/$BADGE_REGEX/s|$BADGE_REGEX|$NEW_BADGES|" release_notes.txt
@@ -61,8 +61,9 @@ jobs:
6161
echo "Modified release notes:"
6262
head -n 10 release_notes.txt # Show the modified section
6363
64-
- name: Update previous release with modified notes
64+
- name: Update latest release with modified notes
6565
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
6768
env:
6869
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)