Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: '0 2 * * *'
workflow_dispatch:

permissions:
contents: write

jobs:
nightly:
name: Nightly build
Expand All @@ -28,6 +31,31 @@ jobs:
echo "has_commits=false" >> $env:GITHUB_OUTPUT
}

- name: Read nightly version
if: steps.check.outputs.has_commits == 'true'
id: version
shell: pwsh
env:
RC_NUMBER: ${{ github.run_number }}
run: |
$content = Get-Content -Raw "Trainer_v5/Trainer.Source/Helpers.cs"
$match = [regex]::Match(
$content,
'public\s+static\s+string\s+Version\s*=>\s*"(?<version>\d+\.\d+\.\d+)";'
)

if (-not $match.Success) {
throw "Could not read a semantic version from Helpers.Version."
}

$baseVersion = $match.Groups["version"].Value
$version = "$baseVersion-rc$env:RC_NUMBER"
$commit = git rev-parse HEAD

"version=$version" >> $env:GITHUB_OUTPUT
"tag=v$version" >> $env:GITHUB_OUTPUT
"commit=$commit" >> $env:GITHUB_OUTPUT

- name: Setup .NET
if: steps.check.outputs.has_commits == 'true'
uses: actions/setup-dotnet@v4
Expand All @@ -36,7 +64,7 @@ jobs:

- name: Build (Release)
if: steps.check.outputs.has_commits == 'true'
run: dotnet build "Trainer v5 - Beta 1.sln" --configuration Release --no-incremental
run: dotnet build "Trainer v5 - Beta 1.sln" --configuration Release --no-incremental --property:Version=${{ steps.version.outputs.version }}

- name: Stage release files
if: steps.check.outputs.has_commits == 'true'
Expand All @@ -49,23 +77,25 @@ jobs:
- name: Package
if: steps.check.outputs.has_commits == 'true'
shell: pwsh
run: Compress-Archive -Path release/* -DestinationPath Trainer_v5.zip
run: Compress-Archive -Path release/* -DestinationPath Trainer_v5_${{ steps.version.outputs.version }}.zip

- name: Upload artifact
if: steps.check.outputs.has_commits == 'true'
uses: actions/upload-artifact@v4
with:
name: Trainer_v5_nightly
path: Trainer_v5.zip
name: Trainer_v5_${{ steps.version.outputs.version }}
path: Trainer_v5_${{ steps.version.outputs.version }}.zip
if-no-files-found: error

- name: Create nightly release
if: steps.check.outputs.has_commits == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Nightly
files: Trainer_v5.zip
tag_name: ${{ steps.version.outputs.tag }}
name: Trainer v${{ steps.version.outputs.version }}
target_commitish: ${{ steps.version.outputs.commit }}
files: Trainer_v5_${{ steps.version.outputs.version }}.zip
draft: false
prerelease: true
generate_release_notes: false
make_latest: false
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ See [`AGENTS.md`](AGENTS.md) for full branching rules and coding conventions.
| Trigger | Workflow | Result |
|---------|----------|--------|
| Push or PR to `develop` | CI | Build check |
| Daily schedule or manual dispatch | Nightly | Build + versioned RC artifact + prerelease |
| Push to `main` | Release | Build + versioned zip artifact + versioned GitHub Release |

The release workflow reads the semantic version from `Helpers.Version`. A release creates the matching `v<major>.<minor>.<patch>` tag and uses the version in the downloadable archive name. Increase `Helpers.Version` before merging another release to `main`.

The nightly workflow appends the workflow run number as an RC suffix, producing versions such as `5.2.6-rc123`. Nightly prereleases do not replace the latest stable release.
Loading