-
Notifications
You must be signed in to change notification settings - Fork 177
Improve nightly build PR check and logging #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f510417
323f148
c22fc95
1aee357
8bd0b28
b28f7a8
ae51f88
14a308b
7cd77b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,41 +40,92 @@ jobs: | |
| id: check_prs | ||
| shell: powershell | ||
| run: | | ||
| # Get the latest release tag (any type) | ||
| Write-Host "========================================" -ForegroundColor Cyan | ||
| Write-Host "Checking for new changes since last release" -ForegroundColor Cyan | ||
| Write-Host "========================================" -ForegroundColor Cyan | ||
|
|
||
| # Get the latest release tag to determine release type | ||
| $LATEST_TAG = git tag -l --sort=-version:refname | Select-Object -First 1 | ||
| Write-Host "Latest release: $LATEST_TAG" | ||
|
|
||
| # Get all merged PRs since last tag (only merge commits from PRs) | ||
| $MERGED_PRS = git log --merges --grep="Merge pull request" --pretty=format:"%h %s" "$LATEST_TAG..develop" | ||
|
|
||
| # Count merges | ||
| $MERGE_COUNT = ($MERGED_PRS | Measure-Object).Count | ||
|
|
||
| if ($MERGE_COUNT -eq 0) { | ||
| Write-Host "No PRs merged to develop since last tag. Skipping build." | ||
| $BUILD_NEEDED = $false | ||
| Write-Host "`n[INFO] Latest release tag: $LATEST_TAG" -ForegroundColor Green | ||
|
|
||
| # Determine release type based on previous tag | ||
| if ($LATEST_TAG -like "*-*") { | ||
| # Previous tag is a prerelease -> increment suffix (e.g., v2.9.1-0 -> v2.9.1-1) | ||
| $RELEASE_TYPE = "prerelease" | ||
| Write-Host "[INFO] Previous tag is a prerelease -> using 'prerelease' to increment suffix" -ForegroundColor Cyan | ||
| } else { | ||
| # Previous tag is stable -> create first prerelease (e.g., v2.9.0 -> v2.10.0-0) | ||
| $RELEASE_TYPE = "preminor" | ||
| Write-Host "[INFO] Previous tag is stable -> using 'preminor' to create first prerelease" -ForegroundColor Cyan | ||
| } | ||
|
|
||
| # Manual trigger always builds | ||
| if ("${{ github.event_name }}" -eq "workflow_dispatch") { | ||
| Write-Host "`n[MANUAL] Manual trigger detected - forcing build" -ForegroundColor Magenta | ||
| Write-Host "[BUILD] Building new prerelease version (type: $RELEASE_TYPE)." -ForegroundColor Green | ||
| $BUILD_NEEDED = $true | ||
| } | ||
| else { | ||
| Write-Host "Merged PRs since last tag (develop):" | ||
| Write-Host $MERGED_PRS | ||
|
|
||
| if ($MERGE_COUNT -eq 1 -and $MERGED_PRS -match "Merge pull request #\d+ from .*/release/") { | ||
| Write-Host "Only change since last tag is a release PR merge. Skipping build." | ||
| # Automated nightly: check for changes first | ||
| Write-Host "`n[AUTO] Scheduled nightly build - checking for changes..." -ForegroundColor Cyan | ||
|
|
||
| # Get the commit date of the latest tag (compatible with PowerShell 5.1) | ||
| $TAG_DATE = git log -1 --format=%ct $LATEST_TAG | ||
Romanitho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| $TAG_DATE_FORMATTED = git log -1 --format=%ci $LATEST_TAG | ||
| Write-Host "[INFO] Tag creation date: $TAG_DATE_FORMATTED" -ForegroundColor Green | ||
|
|
||
| # Get tag commit SHA | ||
| $TAG_COMMIT = git rev-list -n 1 $LATEST_TAG | ||
| Write-Host "[INFO] Tag commit SHA: $TAG_COMMIT" -ForegroundColor Green | ||
|
|
||
| # Get current branch and HEAD commit | ||
| $BRANCH = "${{ env.BRANCH }}" | ||
| $HEAD_COMMIT = git rev-parse HEAD | ||
| Write-Host "[INFO] Current branch: $BRANCH" -ForegroundColor Green | ||
| Write-Host "[INFO] Current HEAD: $HEAD_COMMIT" -ForegroundColor Green | ||
|
|
||
| # Check if tag commit is the same as HEAD | ||
| if ($TAG_COMMIT -eq $HEAD_COMMIT) { | ||
| Write-Host "`n[SKIP] Tag commit is identical to current HEAD. No new changes." -ForegroundColor Yellow | ||
| $BUILD_NEEDED = $false | ||
| } | ||
| else { | ||
| $BUILD_NEEDED = $true | ||
|
|
||
| # Set release type for output (adapts to your previous logic if you need it) | ||
| if ($LATEST_TAG -like "*-*") { | ||
| $RELEASE_TYPE = "prerelease" | ||
| } else { | ||
| $RELEASE_TYPE = "preminor" | ||
| Write-Host "`n[INFO] Searching for merged PRs between $TAG_COMMIT and HEAD..." -ForegroundColor Cyan | ||
|
|
||
| # Get all merged PRs to the branch since the tag commit | ||
| $MERGED_PRS = git log $BRANCH --merges --grep="Merge pull request" --pretty=format:"%h %s" "$TAG_COMMIT..HEAD" | ||
Romanitho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Count merges | ||
| $MERGE_COUNT = ($MERGED_PRS | Measure-Object).Count | ||
| Write-Host "[INFO] Found $MERGE_COUNT merged PR(s)" -ForegroundColor Green | ||
|
|
||
| if ($MERGE_COUNT -eq 0) { | ||
| Write-Host "`n[SKIP] No PRs merged to $BRANCH since last tag. Skipping build." -ForegroundColor Yellow | ||
| $BUILD_NEEDED = $false | ||
| } | ||
| else { | ||
| Write-Host "`n[INFO] Merged PRs since last tag:" -ForegroundColor Cyan | ||
| $MERGED_PRS | ForEach-Object { Write-Host " - $_" -ForegroundColor White } | ||
|
|
||
| if ($MERGE_COUNT -eq 1 -and $MERGED_PRS -match "Merge pull request #\d+ from .*/release/") { | ||
| Write-Host "`n[SKIP] Only change since last tag is a release PR merge. Skipping build." -ForegroundColor Yellow | ||
| $BUILD_NEEDED = $false | ||
| } | ||
| else { | ||
| Write-Host "`n[BUILD] Building new prerelease version (type: $RELEASE_TYPE)." -ForegroundColor Green | ||
| $BUILD_NEEDED = $true | ||
| } | ||
| } | ||
| echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT | ||
| } | ||
| } | ||
|
|
||
| Write-Host "`n========================================" -ForegroundColor Cyan | ||
| Write-Host "Build needed: $BUILD_NEEDED" -ForegroundColor $(if ($BUILD_NEEDED -eq $true) { "Green" } else { "Yellow" }) | ||
| Write-Host "Release type: $RELEASE_TYPE" -ForegroundColor Cyan | ||
| Write-Host "========================================" -ForegroundColor Cyan | ||
|
|
||
| echo "BUILD_NEEDED=$BUILD_NEEDED" >> $env:GITHUB_OUTPUT | ||
|
||
| echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT | ||
|
||
|
|
||
| # Step 3: Generate new semantic version number | ||
| - name: Auto Increment Semver Action | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.