Skip to content

Commit 217ef7b

Browse files
committed
chore: update workflow
1 parent bf3f18d commit 217ef7b

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

.github/workflows/beta-release.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,48 @@ jobs:
126126

127127
- name: "Install dependencies"
128128
if: steps.check_release_tag.outputs.SHOULD_RELEASE == 'true'
129-
run: pnpm install
129+
run: |
130+
# Install jq for JSON parsing
131+
sudo apt-get update && sudo apt-get install -y jq
132+
pnpm install
130133
131134
- name: "Get version from package.json"
132135
if: steps.check_release_tag.outputs.SHOULD_RELEASE == 'true'
133136
id: get_version
134137
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
135138

136-
- name: "Get commit messages since last tag"
139+
- name: "Get commit messages since last release"
137140
if: steps.check_release_tag.outputs.SHOULD_RELEASE == 'true'
138141
id: get_commits
139142
run: |
140-
# Get the most recent tag (including pre-releases)
141-
LAST_TAG=$(git tag --sort=-version:refname | head -n 1 2>/dev/null || echo "")
143+
# Get all releases (including pre-releases) and find the most recent one
144+
echo "Fetching all releases from GitHub API..."
145+
LAST_RELEASE=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases?per_page=100" | jq -r '.[0].tag_name // empty' 2>/dev/null || echo "")
146+
147+
# If no release found via API, try to get the most recent tag with proper semantic version sorting
148+
if [ -z "$LAST_RELEASE" ]; then
149+
echo "No release found via API, looking for latest tag..."
150+
# Get all tags and sort them properly using semantic versioning
151+
LAST_RELEASE=$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1 2>/dev/null || echo "")
152+
fi
142153
143-
if [ -z "$LAST_TAG" ]; then
144-
echo "No previous tag found, getting all commits from the beginning"
154+
if [ -z "$LAST_RELEASE" ]; then
155+
echo "No previous release or tag found, getting all commits from the beginning"
145156
COMMIT_MESSAGES=$(git log --pretty=format:"- %s (%an) [%h](https://github.com/${{ github.repository }}/commit/%H)" --no-merges)
157+
LAST_RELEASE="(initial)"
146158
else
147-
echo "Getting commits since last tag: $LAST_TAG"
148-
TAG_COMMIT=$(git rev-list -n 1 $LAST_TAG)
149-
COMMIT_MESSAGES=$(git log ${TAG_COMMIT}..HEAD --pretty=format:"- %s (%an) [%h](https://github.com/${{ github.repository }}/commit/%H)" --no-merges)
159+
echo "Getting commits since last release: $LAST_RELEASE"
160+
RELEASE_COMMIT=$(git rev-list -n 1 $LAST_RELEASE 2>/dev/null || git rev-list -n 1 HEAD~10)
161+
COMMIT_MESSAGES=$(git log ${RELEASE_COMMIT}..HEAD --pretty=format:"- %s (%an) [%h](https://github.com/${{ github.repository }}/commit/%H)" --no-merges)
150162
fi
151163
152164
if [ -z "$COMMIT_MESSAGES" ]; then
153-
COMMIT_MESSAGES="- No new commits since last tag"
165+
COMMIT_MESSAGES="- No new commits since last release"
154166
fi
155167
echo "COMMIT_MESSAGES<<EOF" >> $GITHUB_ENV
156168
echo "$COMMIT_MESSAGES" >> $GITHUB_ENV
157169
echo "EOF" >> $GITHUB_ENV
158-
echo "LAST_TAG=$LAST_TAG" >> $GITHUB_ENV
170+
echo "LAST_RELEASE=$LAST_RELEASE" >> $GITHUB_ENV
159171
160172
- name: "Build and package plugin"
161173
if: steps.check_release_tag.outputs.SHOULD_RELEASE == 'true'
@@ -173,7 +185,7 @@ jobs:
173185
body: |
174186
${{ github.event_name == 'pull_request' && format('🚀 Automated beta release for PR #{0}', github.event.pull_request.number) || '🚀 Automated beta release' }}
175187
176-
## 📝 Changes since last tag${{ env.LAST_TAG && format(' ({0})', env.LAST_TAG) || '' }}:
188+
## 📝 Changes since last release${{ env.LAST_RELEASE && format(' ({0})', env.LAST_RELEASE) || '' }}:
177189
178190
${{ env.COMMIT_MESSAGES }}
179191

0 commit comments

Comments
 (0)