Manual Release - Develop #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Manual Release - Develop" | |
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: 'SRTPluginBase.sln' | |
PROJECT: 'src/SRTPluginBase/SRTPluginBase.csproj' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
- 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: 7.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: Decode the pfx | |
run: | | |
Set-Content -Path 'CodeSign.txt' -Value '${{ secrets.CODE_SIGN_CERTIFICATE }}' | |
certutil -decode 'CodeSign.txt' 'CodeSign.pfx' | |
Remove-Item -Path 'CodeSign.txt' | |
# Code signigng certificate went from $233/yr to $633/yr. | |
# They also required an HSM (Hardware Security Module (USB Key)) or a subscription service for signing. | |
# Self-signing certificate yields error NU3018. | |
# As an open source developer who was using code signing certificates as base-64 encoded pfx files stored in GitHub secrets, this 'new way' is untenable and greatly interferes with our workflow. | |
# For now we'll just have to not sign our packages... | |
# - name: Code sign the nupkg | |
# run: | | |
# $filesToZip = (Get-ChildItem -Path 'src/' -Filter *.nupkg -Recurse).fullname | |
# foreach ($fileToZip in $filesToZip) { | |
# & dotnet nuget sign "$fileToZip" --certificate-path "CodeSign.pfx" --certificate-password "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" --timestamper "http://timestamp.digicert.com" | |
# } | |
- name: Publish | |
run: nuget push **\*.nupkg -Source "https://api.nuget.org/v3/index.json" -ApiKey "${{secrets.NUGET_API_KEY}}" -SkipDuplicate |