From c3d7f57228749c991be6febdf874355337a720e2 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 9 Feb 2026 09:25:24 +0800 Subject: [PATCH 1/4] initial --- docs/Contributing.md | 24 +++++++++++++++--------- docs/General-Info.md | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/Contributing.md b/docs/Contributing.md index d2ace5e068..7600d05367 100644 --- a/docs/Contributing.md +++ b/docs/Contributing.md @@ -215,15 +215,21 @@ DEFINE_HOOK(0x48381D, CellClass_SpreadTiberium_CellSpread, 0x6) The styleguide is not exhaustive and may be adjusted in the future. ``` -### Git branching model - -Couple of notes regarding the Git practices. We use [git-flow](https://nvie.com/posts/a-successful-git-branching-model/)-like workflow: - - `master` is for stable releases, can have hotfixes pushed to it or branched off like a feature branch with the requirement of version increment and `master` being merged into `develop` after that; - - `develop` is the main development branch; - - `feature/`-prefixed branches (sometimes the prefix may be different if appropriate, like for big fixes or changes) are so called "feature branches" - those are branched off `develop` for every new feature to be introduced into it and then merged back. We use squash merge to merge them back in case of smaller branches and sometimes merge commit in case the branch is so big it would be viable to keep it as is. - - `hotfix/`-prefixed branches may be used in a same manner as `feature/`, but with `master` branch, with a requirement of `master` being merged into `develop` after `hotfix/` branch was squash merged into `master`. - - `release/`-prefixed branches are branched off `develop` when a new stable release is slated to allow working on features for a next release and stability improvements for this release. Those are merged with a merge commit into `master` and `develop` with a stable version number increase, after which the stable version is released. -- When you're working with your local & remote branches use **fast-forward** pulls to get the changes from remote branch to local, **don't merge remote branch into local and vice versa**, this creates junk commits and makes things unsquashable. +### Git branching model / Version lifecycle and release strategy + +Starting from version 0.5, Phobos adopts a new release strategy to enable faster and more frequent releases. The lifecycle of a version is as follows: + +1. **Development phase**: New features and changes are committed to the `develop` branch. +2. **Pre-release phase**: When enough features have accumulated on `develop`, a pre-release build (e.g., `v0.5-beta1`) is created. This build marks the start of a new *release branch* (e.g., `release/v0.5`) and signifies that active feature development for version 0.5 is complete. This branch will be used for all subsequent testing and the final stable release. + - During this phase, multiple pre-release builds (which can be called beta, alpha, or release candidate) may be published for wider testing. Between pre-releases on the same branch, there shall be no changes that warrant a changelog addition; in other words — only bug fixes, minor additions, and polish to the existing feature set are allowed. + - Documentation for the version (e.g., `v0.5`) is created at this point and is shared across all its pre-releases and the final stable release, rather than generating separate docs for each pre-release. +3. **Stable release**: When the pre-release builds are deemed stable enough, a stable release (e.g., `v0.5`) is published from the release branch. +4. **Maintenance phase**: After the stable release, the release branch enters maintenance mode, where only bug fixes are applied, resulting in patch releases (e.g., `v0.5.0.1`, `v0.5.0.2`). +5. **End of maintenance**: When a new stable release is published (e.g., `v0.6`), the previous minor version branch (e.g., `v0.5.0.x`) is officially deprecated and enters end-of-life, ceasing to receive any further updates, including bug fixes. Concurrently, the new stable release (e.g., `v0.6`) enters its own maintenance phase, and a new release branch for the next version (e.g., `release/v0.7`) may already have been created from the `develop` branch, initiating its pre-release cycle. + +```{important} +The `master` branch is deprecated; all development occurs in `develop`, and each version branches off from it. +``` These commands will do the following for all repositories on your PC: 1) remove the automatic merge upon pull and replace it with a rebase; diff --git a/docs/General-Info.md b/docs/General-Info.md index 5b1dc16cde..a5012c71b7 100644 --- a/docs/General-Info.md +++ b/docs/General-Info.md @@ -6,7 +6,7 @@ This page lists general info that should be known about the project. There are three main types of Phobos builds: - *stable builds* - those are numbered like your regular versions (something close to semantic versioning, e.g. version 1.2.3 for example) and ideally should contain no bugs, therefore are safe to use in mods; -- *development builds* - those are the builds which contain functionality that needs to be tested. They are numbered plainly starting from 0 and incrementing the number on each release. Mod authors still can include those versions with their mods if they want latest features, though we can't guarantee lack of bugs; +- *pre-release builds* - previously known as *development builds*, these builds mark the start of a new release branch and are used for testing new features before they are finalized. They are numbered with a version and a pre-release suffix (e.g., 0.5-beta1, 0.5-rc2). Mod authors can include these versions with their mods to access the latest features, but we cannot guarantee the absence of bugs; - *nightly builds* - bleeding edge versions which can include prototypes, proofs of concepts, scrapped features etc., in other words - we can't guarantee anything in those builds and they absolutely should NOT be used in mod releases and should only be used to help with development and testing. ```{hint} From 000160d4252e67c1239d3ffd3e66fdb127984055 Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 10 Apr 2026 21:42:37 +0300 Subject: [PATCH 2/4] Update build configurations, metadata and workflows - Remove DevBuild configuration - Release configuration no longer sets IS_RELEASE_VER preprocessor directive, references across codebase changed to use RELEASE definition - Metadata is determined based on preprocessor definitions set based on compiler option BuildType (NIGHTLY, PRERELEASE & RELEASE) - Workflows updated to use the new compiler options and accomodate configuration changes --- .github/actions/build-phobos/action.yml | 6 +- .github/workflows/nightly.yml | 5 +- .github/workflows/pr-nightly.yml | 4 +- Phobos.sln | 7 +- Phobos.vcxproj | 89 +++++++------------------ src/Phobos.cpp | 8 +-- src/Phobos.version.h | 36 +++++----- src/version.rc | 4 +- 8 files changed, 61 insertions(+), 98 deletions(-) diff --git a/.github/actions/build-phobos/action.yml b/.github/actions/build-phobos/action.yml index d818a510a3..fee486c3c0 100644 --- a/.github/actions/build-phobos/action.yml +++ b/.github/actions/build-phobos/action.yml @@ -7,6 +7,10 @@ inputs: build-config: description: 'Configuration to build' required: true + build-type: + description: 'Build type e.g nightly, prerelease or release' + required: true + default: 'NIGHTLY' runs: using: "composite" steps: @@ -21,7 +25,7 @@ runs: working-directory: ${{env.GITHUB_WORKSPACE}} # Add additional options to the MSBuild command line here (like platform or verbosity level). # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference - run: msbuild /m /p:Configuration=${{inputs.build-config}} /p:GitCommit=${{github.sha}} /p:GitBranch=${{github.ref}} ${{inputs.sln-path}} + run: msbuild /m /p:Configuration=${{inputs.build-config}} /p:GitCommit=${{github.sha}} /p:GitBranch=${{github.ref}} /p:BuildType=${{inputs.build-type}} ${{inputs.sln-path}} shell: cmd - name: Upload Artifact diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a72f06476a..0f84ef6a75 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -3,8 +3,6 @@ name: Nightly Build on: push: branches: - - master - - main - develop env: @@ -14,7 +12,7 @@ env: # Configuration type to build. # You can convert this to a build matrix if you need coverage of multiple configuration types. # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - BUILD_CONFIGURATION: DevBuild + BUILD_CONFIGURATION: Release # GIT_COMMIT: $(git rev-parse --short "$GITHUB_SHA") # GIT_BRANCH: ${GITHUB_REF#refs/heads/} @@ -32,3 +30,4 @@ jobs: with: sln-path: ${{env.SOLUTION_FILE_PATH}} build-config: ${{env.BUILD_CONFIGURATION}} + build-type: NIGHTLY diff --git a/.github/workflows/pr-nightly.yml b/.github/workflows/pr-nightly.yml index ad7d13bd27..2f9b337c0b 100644 --- a/.github/workflows/pr-nightly.yml +++ b/.github/workflows/pr-nightly.yml @@ -10,7 +10,7 @@ env: # Configuration type to build. # You can convert this to a build matrix if you need coverage of multiple configuration types. # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - BUILD_CONFIGURATION: DevBuild + BUILD_CONFIGURATION: Release # GIT_COMMIT: $(git rev-parse --short "$GITHUB_SHA") # GIT_BRANCH: ${GITHUB_REF#refs/heads/} @@ -29,3 +29,5 @@ jobs: with: sln-path: ${{env.SOLUTION_FILE_PATH}} build-config: ${{env.BUILD_CONFIGURATION}} + build-type: NIGHTLY + diff --git a/Phobos.sln b/Phobos.sln index cb404798b9..d5ed44ff6f 100644 --- a/Phobos.sln +++ b/Phobos.sln @@ -1,21 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29209.62 +# Visual Studio Version 18 +VisualStudioVersion = 18.4.11626.88 stable MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Phobos", "Phobos.vcxproj", "{3FAF7126-F38C-4D1E-9973-C21A37870F60}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 - DevBuild|x86 = DevBuild|x86 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {3FAF7126-F38C-4D1E-9973-C21A37870F60}.Debug|x86.ActiveCfg = Debug|Win32 {3FAF7126-F38C-4D1E-9973-C21A37870F60}.Debug|x86.Build.0 = Debug|Win32 - {3FAF7126-F38C-4D1E-9973-C21A37870F60}.DevBuild|x86.ActiveCfg = DevBuild|Win32 - {3FAF7126-F38C-4D1E-9973-C21A37870F60}.DevBuild|x86.Build.0 = DevBuild|Win32 {3FAF7126-F38C-4D1E-9973-C21A37870F60}.Release|x86.ActiveCfg = Release|Win32 {3FAF7126-F38C-4D1E-9973-C21A37870F60}.Release|x86.Build.0 = Release|Win32 EndGlobalSection diff --git a/Phobos.vcxproj b/Phobos.vcxproj index d45a6ac91f..552f1e461d 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -8,10 +8,6 @@ Debug Win32 - - DevBuild - Win32 - Release Win32 @@ -351,13 +347,6 @@ NotSet false - - DynamicLibrary - false - v143 - NotSet - false - DynamicLibrary false @@ -373,9 +362,6 @@ - - - @@ -387,13 +373,6 @@ $(Configuration)\ $(Configuration)\IntDir\ - - false - $(SolutionDir)src\;$(SolutionDir)src\ExtraHeaders;$(SolutionDir)yrpp;$(SolutionDir)lib;$(VC_IncludePath) - false - $(Configuration)\ - $(Configuration)\IntDir\ - false $(SolutionDir)src\;$(SolutionDir)src\ExtraHeaders;$(SolutionDir)yrpp;$(SolutionDir)lib;$(VC_IncludePath) @@ -410,7 +389,7 @@ true Caret true - IS_RELEASE_VER;SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll" + NIGHTLY;SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll" true false MultiThreaded @@ -446,48 +425,6 @@ IS_RELEASE_VER;%(PreprocessorDefinitions) - - - Level4 - MaxSpeed - true - - true - Caret - true - SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll" - true - false - MultiThreaded - 8Bytes - false - false - StreamingSIMDExtensions2 - true - false - stdcpp20 - $(IntDir)\%(RelativeDir) - $(IntDir)\%(RelativeDir) - StdCall - %(AdditionalOptions) - 4100;4201;4530;4731;4740;4458;4819;5103;5105 - true - true - true - - - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dbghelp.lib;onecore.lib;%(AdditionalDependencies) - Windows - $(OutDir)$(TargetName).pdb - $(IntDir)$(TargetName).pgd - $(IntDir)$(TargetName).lib - - - - - Level4 @@ -548,6 +485,30 @@ /DGIT_BRANCH="$(GitBranch)" %(AdditionalOptions) + + + NIGHTLY;%(PreprocessorDefinitions) + + + NIGHTLY;%(PreprocessorDefinitions) + + + + + PRERELEASE;%(PreprocessorDefinitions) + + + PRERELEASE;%(PreprocessorDefinitions) + + + + + RELEASE;%(PreprocessorDefinitions) + + + RELEASE;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/src/Phobos.cpp b/src/Phobos.cpp index c061b50170..f324f1af2d 100644 --- a/src/Phobos.cpp +++ b/src/Phobos.cpp @@ -10,7 +10,7 @@ #include "Utilities/AresHelper.h" #include "Utilities/Parser.h" -#ifndef IS_RELEASE_VER +#ifndef RELEASE bool HideWarning = false; #endif @@ -30,7 +30,7 @@ bool Phobos::Optimizations::DisableSyncLogging = false; #ifdef STR_GIT_COMMIT const wchar_t* Phobos::VersionDescription = L"Phobos nightly build (" STR_GIT_COMMIT L" @ " STR_GIT_BRANCH L"). DO NOT SHIP IN MODS!"; -#elif !defined(IS_RELEASE_VER) +#elif !defined(RELEASE) const wchar_t* Phobos::VersionDescription = L"Phobos development build #" _STR(BUILD_NUMBER) L". Please test the build before shipping."; #else //const wchar_t* Phobos::VersionDescription = L"Phobos release build v" FILE_VERSION_STR L"."; @@ -59,7 +59,7 @@ void Phobos::CmdLineParse(char** ppArgs, int nNumArgs) { Phobos::AppIconPath = ppArgs[++i]; } -#ifndef IS_RELEASE_VER +#ifndef RELEASE if (_stricmp(pArg, "-b=" _STR(BUILD_NUMBER)) == 0) { HideWarning = true; @@ -232,7 +232,7 @@ DEFINE_HOOK(0x683E7F, ScenarioClass_Start_Optimizations, 0x7) return 0; } -#ifndef IS_RELEASE_VER +#ifndef RELEASE DEFINE_HOOK(0x4F4583, GScreenClass_DrawText, 0x6) { #ifndef STR_GIT_COMMIT diff --git a/src/Phobos.version.h b/src/Phobos.version.h index abd7d3237b..657e50c3ab 100644 --- a/src/Phobos.version.h +++ b/src/Phobos.version.h @@ -22,32 +22,32 @@ #pragma endregion -// Build number. Incremented on each released build. -#define BUILD_NUMBER 48 +// Pre-release build number. Incremented on each pre-release build. +#define PRERELEASE_NUM 1 // Nightly defines GIT_COMMIT and GIT_BRANCH in GH Actions +// NIGHTLY / PRERELEASE / RELEASE come from compiler option BuildType - used by GH Actions as well -#ifdef IS_RELEASE_VER // Release build metadata - #define SAVEGAME_ID ((VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (VERSION_REVISION << 8) | VERSION_PATCH) - #define FILE_DESCRIPTION "Phobos, Ares-compatible YR engine extension" - #define FILE_VERSION_STR _STR(VERSION_MAJOR) "." _STR(VERSION_MINOR) "." _STR(VERSION_REVISION) "." _STR(VERSION_PATCH) - #define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH - #define PRODUCT_VERSION "Release Build " FILE_VERSION_STR -#elif defined(GIT_COMMIT) // Nightly devbuild metadata +#if defined(NIGHTLY) #define STR_GIT_COMMIT _STR(GIT_COMMIT) #define STR_GIT_BRANCH _STR(GIT_BRANCH) - - #define SAVEGAME_ID ((BUILD_NUMBER << 24) | (BUILD_NUMBER << 12) | (BUILD_NUMBER)) - #define FILE_DESCRIPTION "Unstable nightly devbuild of Phobos engine extension" + #define SAVEGAME_ID ((VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (VERSION_REVISION << 8) | VERSION_PATCH) + #define FILE_DESCRIPTION "Unstable nightly build of Phobos engine extension" #define FILE_VERSION_STR "Commit " STR_GIT_COMMIT #define FILE_VERSION 0 #define PRODUCT_VERSION "Nightly Build " STR_GIT_COMMIT " @ " STR_GIT_BRANCH -#else // Regular devbuild metadata - #define SAVEGAME_ID ((BUILD_NUMBER << 24) | (BUILD_NUMBER << 12) | (BUILD_NUMBER)) - #define FILE_DESCRIPTION "Development build of Phobos engine extension" - #define FILE_VERSION_STR "Build #" _STR(BUILD_NUMBER) - #define FILE_VERSION 0,0,0,BUILD_NUMBER - #define PRODUCT_VERSION "Development Build #" _STR(BUILD_NUMBER) +#elif defined(PRERELEASE) + #define SAVEGAME_ID ((VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (PRERELEASE_NUM << 8)) + #define FILE_DESCRIPTION "Pre-release build of Phobos, Ares-compatible YR engine extension" + #define FILE_VERSION_STR _STR(VERSION_MAJOR) "." _STR(VERSION_MINOR) "-beta" _STR(PRERELEASE_NUM) + #define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, 0, 0 + #define PRODUCT_VERSION "v." _STR(VERSION_MAJOR) "." _STR(VERSION_MINOR) "-beta" _STR(PRERELEASE_NUM) +#else + #define SAVEGAME_ID ((VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (VERSION_REVISION << 8) | VERSION_PATCH) + #define FILE_DESCRIPTION "Phobos, Ares-compatible YR engine extension" + #define FILE_VERSION_STR _STR(VERSION_MAJOR) "." _STR(VERSION_MINOR) "." _STR(VERSION_REVISION) "." _STR(VERSION_PATCH) + #define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH + #define PRODUCT_VERSION "v." FILE_VERSION_STR #endif #endif // VERSION_H diff --git a/src/version.rc b/src/version.rc index 394625a99e..240a811ea9 100644 --- a/src/version.rc +++ b/src/version.rc @@ -9,7 +9,7 @@ ID_VERSION VERSIONINFO FILEVERSION FILE_VERSION PRODUCTVERSION FILE_VERSION FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifndef IS_RELEASE_VER +#ifndef RELEASE FILEFLAGS VS_FF_PRERELEASE | VS_FF_SPECIALBUILD #endif @@ -29,7 +29,7 @@ BEGIN VALUE "InternalName", "Phobos.dll\0" VALUE "OriginalFilename", "Phobos.dll\0" -#ifndef IS_RELEASE_VER +#ifndef RELEASE VALUE "SpecialBuild", "Testing version. Use at your own risk.\0" #endif END From 9178a76ff280c394d3196c6ba9094409231ed281 Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 10 Apr 2026 21:51:43 +0300 Subject: [PATCH 3/4] Fix minor error from testing --- Phobos.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Phobos.vcxproj b/Phobos.vcxproj index 552f1e461d..18a895d600 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -389,7 +389,7 @@ true Caret true - NIGHTLY;SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll" + SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll" true false MultiThreaded From a918fd9d75b66c41d48df8b6a8c1acd3e9acd409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:38:00 +0800 Subject: [PATCH 4/4] auto release and changelog --- .github/workflows/release.yml | 63 ++++++++++++++++++++++++ scripts/extract_changelog.ps1 | 93 +++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 scripts/extract_changelog.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..6c3d40b5dc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release Build + +on: + release: + types: [published] + +env: + SOLUTION_FILE_PATH: . + BUILD_CONFIGURATION: Release + +permissions: + contents: write + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + + - name: Determine Build Type and Version Info + id: info + shell: pwsh + run: | + $tag = "${{ github.ref_name }}" + $version = $tag.TrimStart('v') + $isPrerelease = "${{ github.event.release.prerelease }}" + if ($isPrerelease -eq "true") { + $buildType = "PRERELEASE" + $releaseName = "Phobos $tag (Pre-release)" + } else { + $buildType = "RELEASE" + $releaseName = "Phobos $tag" + } + echo "build-type=$buildType" >> $env:GITHUB_OUTPUT + echo "version=$version" >> $env:GITHUB_OUTPUT + echo "release-name=$releaseName" >> $env:GITHUB_OUTPUT + + - name: Build Phobos + uses: ./.github/actions/build-phobos + with: + sln-path: ${{env.SOLUTION_FILE_PATH}} + build-config: ${{ env.BUILD_CONFIGURATION }} + build-type: ${{ steps.info.outputs.build-type }} + + - name: Extract Changelog + shell: pwsh + run: | + .\scripts\extract_changelog.ps1 ` + -Tag "${{ github.ref_name }}" ` + -WhatsNewPath docs\Whats-New.md ` + -OutputPath RELEASE_NOTES.md + + - name: Upload Release Assets + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.info.outputs.release-name }} + files: | + ${{ env.BUILD_CONFIGURATION }}/Phobos.dll + ${{ env.BUILD_CONFIGURATION }}/Phobos.pdb + body_path: RELEASE_NOTES.md diff --git a/scripts/extract_changelog.ps1 b/scripts/extract_changelog.ps1 new file mode 100644 index 0000000000..2f565595d0 --- /dev/null +++ b/scripts/extract_changelog.ps1 @@ -0,0 +1,93 @@ +param( + [Parameter(Mandatory = $true)] + [string]$Tag, + + [Parameter(Mandatory = $true)] + [string]$WhatsNewPath, + + [Parameter(Mandatory = $true)] + [string]$OutputPath +) + +$version = $Tag.TrimStart('v') + +if (-not (Test-Path $WhatsNewPath)) { + Write-Error "File not found: $WhatsNewPath" + exit 1 +} + +$content = (Get-Content -Path $WhatsNewPath -Raw -Encoding utf8) -replace "`r`n", "`n" + +$changelogIdx = $content.IndexOf("## Changelog") +if ($changelogIdx -lt 0) { + Write-Error "Could not find '## Changelog' section in $WhatsNewPath" + exit 1 +} + +$afterChangelog = $content.Substring($changelogIdx + "## Changelog".Length + 1) + +$nextSectionIdx = $afterChangelog.IndexOf("`n## ") +$changelogBody = if ($nextSectionIdx -ge 0) { $afterChangelog.Substring(0, $nextSectionIdx) } else { $afterChangelog } + +# Try to find the section: exact version -> parent versions -> Version TBD +$sectionStart = -1 + +# 1) Exact version match +$sectionStart = $changelogBody.IndexOf("### $version`n") + +# 2) Strip trailing numeric components until found +if ($sectionStart -lt 0) { + $tryVersion = $version -replace '\.[0-9]+$', '' + while ($tryVersion -ne $version) { + $sectionStart = $changelogBody.IndexOf("### $tryVersion`n") + if ($sectionStart -ge 0) { break } + $version = $tryVersion + $tryVersion = $version -replace '\.[0-9]+$', '' + } + $version = $Tag.TrimStart('v') # restore original +} + +# 3) Fall back to Version TBD +if ($sectionStart -lt 0) { + $sectionStart = $changelogBody.IndexOf("### Version TBD") +} + +if ($sectionStart -lt 0) { + Write-Error "Could not find changelog section for version '$version' or 'Version TBD'" + exit 1 +} + +$sectionEnd = $changelogBody.IndexOf("`n### ", $sectionStart + 5) +if ($sectionEnd -ge 0) { + $sectionContent = $changelogBody.Substring($sectionStart, $sectionEnd - $sectionStart) +} else { + $sectionContent = $changelogBody.Substring($sectionStart) +} + +$firstNewline = $sectionContent.IndexOf("`n") +if ($firstNewline -ge 0) { + $sectionContent = $sectionContent.Substring($firstNewline + 1) +} else { + $sectionContent = "" +} + +$sectionContent = $sectionContent.Trim() + +$dropdownPattern = '(?ms)^```\{dropdown\}[^\n]*\n(.+?)^```' +$dropdownMatch = [regex]::Match($sectionContent, $dropdownPattern) + +if ($dropdownMatch.Success) { + $sectionContent = $dropdownMatch.Groups[1].Value.Trim() +} + +$sectionContent = $sectionContent -replace '(?m)^:open:\s*\n', '' +$sectionContent = $sectionContent.Trim() + +if (-not $sectionContent) { + Write-Error "Extracted changelog content is empty for version '$version'" + exit 1 +} + +$sectionContent | Out-File -FilePath $OutputPath -Encoding utf8 + +Write-Host "Extracted changelog for version '$version' to '$OutputPath'"