Skip to content

Manual Release

Manual Release #84

name: "Manual Release"
on:
workflow_dispatch:
inputs:
buildConfig:
description: "Build configuration"
required: true
default: "Debug"
type: choice
options:
- "Debug"
- "Release"
releaseTypeTag: # Use -alpha, -beta, or -rc for pre-release. An empty string for stable.
description: "Release type tag"
required: true
default: "-beta"
type: choice
options:
- "-alpha"
- "-beta"
- "-RC"
- ""
jobs:
build:
name: "Build"
runs-on: "windows-latest"
env:
BUILD_PLATFORM: "Any CPU"
SOLUTION: "src/SRTPluginBase.slnx"
PROJECT: "src/SRTPluginBase/SRTPluginBase.csproj"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get current UTC DateTime
id: get-datetime
run: echo ('UTCDateTime=' + [System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss")) >> $env:GITHUB_OUTPUT
- name: Get project version information
id: project-versions
run: Select-String -Path "$env:PROJECT" '<(?<TagName>\w*?Version)>(?<Major>\d+)(?:\.(?<Minor>\d+))(?:\.(?<Patch>\d+)|-(?<Quality>\w+)|\+(?<Tag>\w+))?(?:\.(?<Patch>\d+)|-(?<Quality>\w+)|\+(?<Tag>\w+))?(?:\.(?<Patch>\d+)|-(?<Quality>\w+)|\+(?<Tag>\w+))?</\w*?Version>' -AllMatches | Foreach-Object -Process {$_.Matches} | Foreach-Object -Process { $tagName = $_.Groups["TagName"].Value; $_.Groups | Where-Object { $_.Name -ne "0" -and $_.Name -ne "TagName"; } } | Foreach-Object -Process { $tagName + "_" + $_.Name + "=" + $_.Value >> $env:GITHUB_OUTPUT }
- name: Set project version string
id: project-version-string
run: |
echo 'Version=${{steps.project-versions.outputs.Version_Major}}.${{steps.project-versions.outputs.Version_Minor}}.${{steps.project-versions.outputs.Version_Patch}}${{inputs.releaseTypeTag}}.${{steps.get-datetime.outputs.UTCDateTime}}' >> $env:GITHUB_OUTPUT
- name: Ensure we detected the version properly
id: assert-version
if: ${{ steps.project-version-string.outputs.Version == format('..{0}.', inputs.releaseTypeTag) }}
run: exit 1
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 10.0.x
dotnet-quality: "ga"
- name: Restore
run: dotnet restore $env:SOLUTION --verbosity normal
- name: Build
run: dotnet build $env:SOLUTION /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=${{steps.project-version-string.outputs.Version}}" --no-restore --verbosity normal
- name: Run tests
run: dotnet test /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=${{steps.project-version-string.outputs.Version}}" --no-restore --no-build --verbosity normal
- name: Publish
run: nuget push **\*.nupkg -Source "https://api.nuget.org/v3/index.json" -ApiKey "${{secrets.NUGET_API_KEY}}" -SkipDuplicate