@@ -40,41 +40,94 @@ jobs:
4040 id : check_prs
4141 shell : powershell
4242 run : |
43- # Get the latest release tag (any type)
43+ Write-Host "========================================" -ForegroundColor Cyan
44+ Write-Host "Checking for new changes since last release" -ForegroundColor Cyan
45+ Write-Host "========================================" -ForegroundColor Cyan
46+
47+ # Initialize BUILD_NEEDED with default value
48+ $BUILD_NEEDED = $false
49+
50+ # Get the latest release tag to determine release type
4451 $LATEST_TAG = git tag -l --sort=-version:refname | Select-Object -First 1
45- Write-Host "Latest release: $LATEST_TAG"
46-
47- # Get all merged PRs since last tag (only merge commits from PRs)
48- $MERGED_PRS = git log --merges --grep="Merge pull request" --pretty=format:"%h %s" "$LATEST_TAG..develop"
49-
50- # Count merges
51- $MERGE_COUNT = ($MERGED_PRS | Measure-Object).Count
52-
53- if ($MERGE_COUNT -eq 0) {
54- Write-Host "No PRs merged to develop since last tag. Skipping build."
55- $BUILD_NEEDED = $false
52+ Write-Host "`n[INFO] Latest release tag: $LATEST_TAG" -ForegroundColor Green
53+
54+ # Determine release type based on previous tag
55+ if ($LATEST_TAG -like "*-*") {
56+ # Previous tag is a prerelease -> increment suffix (e.g., v2.9.1-0 -> v2.9.1-1)
57+ $RELEASE_TYPE = "prerelease"
58+ Write-Host "[INFO] Previous tag is a prerelease -> using 'prerelease' to increment suffix" -ForegroundColor Cyan
59+ } else {
60+ # Previous tag is stable -> create first prerelease (e.g., v2.9.0 -> v2.10.0-0)
61+ $RELEASE_TYPE = "preminor"
62+ Write-Host "[INFO] Previous tag is stable -> using 'preminor' to create first prerelease" -ForegroundColor Cyan
63+ }
64+
65+ # Manual trigger always builds
66+ if ("${{ github.event_name }}" -eq "workflow_dispatch") {
67+ Write-Host "`n[MANUAL] Manual trigger detected - forcing build" -ForegroundColor Magenta
68+ Write-Host "[BUILD] Building new prerelease version (type: $RELEASE_TYPE)." -ForegroundColor Green
69+ $BUILD_NEEDED = $true
5670 }
5771 else {
58- Write-Host "Merged PRs since last tag (develop):"
59- Write-Host $MERGED_PRS
60-
61- if ($MERGE_COUNT -eq 1 -and $MERGED_PRS -match "Merge pull request #\d+ from .*/release/") {
62- Write-Host "Only change since last tag is a release PR merge. Skipping build."
72+ # Automated nightly: check for changes first
73+ Write-Host "`n[AUTO] Scheduled nightly build - checking for changes..." -ForegroundColor Cyan
74+
75+ # Get the commit date of the latest tag (compatible with PowerShell 5.1)
76+ $TAG_DATE_FORMATTED = git log -1 --format=%ci $LATEST_TAG
77+ Write-Host "[INFO] Tag creation date: $TAG_DATE_FORMATTED" -ForegroundColor Green
78+
79+ # Get tag commit SHA
80+ $TAG_COMMIT = git rev-list -n 1 $LATEST_TAG
81+ Write-Host "[INFO] Tag commit SHA: $TAG_COMMIT" -ForegroundColor Green
82+
83+ # Get current branch and HEAD commit
84+ $BRANCH = "${{ env.BRANCH }}"
85+ $HEAD_COMMIT = git rev-parse HEAD
86+ Write-Host "[INFO] Current branch: $BRANCH" -ForegroundColor Green
87+ Write-Host "[INFO] Current HEAD: $HEAD_COMMIT" -ForegroundColor Green
88+
89+ # Check if tag commit is the same as HEAD
90+ if ($TAG_COMMIT -eq $HEAD_COMMIT) {
91+ Write-Host "`n[SKIP] Tag commit is identical to current HEAD. No new changes." -ForegroundColor Yellow
6392 $BUILD_NEEDED = $false
6493 }
6594 else {
66- $BUILD_NEEDED = $true
67-
68- # Set release type for output (adapts to your previous logic if you need it)
69- if ($LATEST_TAG -like "*-*") {
70- $RELEASE_TYPE = "prerelease"
71- } else {
72- $RELEASE_TYPE = "preminor"
95+ Write-Host "`n[INFO] Searching for merged PRs between $TAG_COMMIT and HEAD..." -ForegroundColor Cyan
96+
97+ # Get all merged PRs to the branch since the tag commit
98+ $MERGED_PRS = git log --merges --grep="Merge pull request" --pretty=format:"%h %s" "$TAG_COMMIT..HEAD"
99+
100+ # Count merges
101+ $MERGE_COUNT = ($MERGED_PRS | Measure-Object).Count
102+ Write-Host "[INFO] Found $MERGE_COUNT merged PR(s)" -ForegroundColor Green
103+
104+ if ($MERGE_COUNT -eq 0) {
105+ Write-Host "`n[SKIP] No PRs merged to $BRANCH since last tag. Skipping build." -ForegroundColor Yellow
106+ $BUILD_NEEDED = $false
107+ }
108+ else {
109+ Write-Host "`n[INFO] Merged PRs since last tag:" -ForegroundColor Cyan
110+ $MERGED_PRS | ForEach-Object { Write-Host " - $_" -ForegroundColor White }
111+
112+ if ($MERGE_COUNT -eq 1 -and $MERGED_PRS -match "Merge pull request #\d+ from .*/release/") {
113+ Write-Host "`n[SKIP] Only change since last tag is a release PR merge. Skipping build." -ForegroundColor Yellow
114+ $BUILD_NEEDED = $false
115+ }
116+ else {
117+ Write-Host "`n[BUILD] Building new prerelease version (type: $RELEASE_TYPE)." -ForegroundColor Green
118+ $BUILD_NEEDED = $true
119+ }
73120 }
74- echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT
75121 }
76122 }
123+
124+ Write-Host "`n========================================" -ForegroundColor Cyan
125+ Write-Host "Build needed: $BUILD_NEEDED" -ForegroundColor $(if ($BUILD_NEEDED -eq $true) { "Green" } else { "Yellow" })
126+ Write-Host "Release type: $RELEASE_TYPE" -ForegroundColor Cyan
127+ Write-Host "========================================" -ForegroundColor Cyan
128+
77129 echo "BUILD_NEEDED=$BUILD_NEEDED" >> $env:GITHUB_OUTPUT
130+ echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT
78131
79132 # Step 3: Generate new semantic version number
80133 - name : Auto Increment Semver Action
0 commit comments