Manual Release - Develop #2
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: | |
working-directory: . | |
project-name: SRTPluginProviderRE2 | |
platform: x64 | |
outputs: | |
project-name: ${{env.project-name}} | |
solution: ${{steps.generated-variables-1.outputs.solution}} | |
project: ${{steps.generated-variables-1.outputs.project}} | |
build-directory: ${{steps.generated-variables-1.outputs.build-directory}} | |
zip-filename: ${{steps.generated-variables-2.outputs.zip-filename}} | |
version: ${{steps.project-version-string.outputs.Version}} | |
steps: | |
# Checkout latest code | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
# Create repo user folder for the dependencies | |
- name: Create repo user folder | |
run: New-Item -ItemType directory -Path ..\..\SpeedRunTool | |
# Checkout latest dependencies code | |
- name: Checkout SRTHost | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
path: SRTHost | |
repository: SpeedRunTool/SRTHost | |
# GITHUB_WORKSPACE pathing is ass. Move this directory down one level. | |
- name: Move SRTHost down a folder to work with existing csproj pathing | |
run: Move-Item -Path SRTHost -Destination ..\..\SpeedRunTool | |
# Checkout latest dependencies code | |
- name: Checkout SRTPluginBase | |
if: inputs.buildConfig == 'Debug' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
path: SRTPluginBase | |
repository: SpeedRunTool/SRTPluginBase | |
# GITHUB_WORKSPACE pathing is ass. Move this directory down one level. | |
- name: Move SRTPluginBase down a folder to work with existing csproj pathing | |
if: inputs.buildConfig == 'Debug' | |
run: Move-Item -Path SRTPluginBase -Destination ..\..\SpeedRunTool | |
# Set some output variables | |
- name: Set the main environment variables based on other environment variables | |
id: generated-variables-1 | |
run: | | |
echo '::set-output name=solution::${{env.project-name}}.sln' | |
echo '::set-output name=project::${{env.project-name}}/${{env.project-name}}.csproj' | |
echo '::set-output name=build-directory::${{env.project-name}}/bin/${{env.platform}}/${{inputs.buildConfig}}/net8.0/' | |
# Get the project's version number | |
- name: Get project version information | |
id: project-versions | |
run: | | |
Select-String -Path "${{steps.generated-variables-1.outputs.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}}' >> $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 | |
# Sets the zip-filename output variable based on the project version | |
- name: Sets the zip-filename environment variable based on the project version | |
id: generated-variables-2 | |
run: | | |
echo '::set-output name=zip-filename::${{env.project-name}}-v${{steps.project-version-string.outputs.Version}}.zip' | |
# Install .NET | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
dotnet-quality: "ga" | |
# Compiles the plugin | |
- name: Compile the plugin | |
run: | | |
dotnet build ${{steps.generated-variables-1.outputs.solution}} -c "${{inputs.buildConfig}}" /p:Platform="${{env.platform}}" | |
- name: Upload publish artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
${{steps.generated-variables-1.outputs.build-directory}}* | |
release: | |
name: "Release" | |
runs-on: "windows-latest" | |
needs: build | |
env: | |
working-directory: . | |
is-prerelease: true | |
steps: | |
# Checkout latest code | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
# Zip the publish artifacts | |
- name: Zip the publish artifacts | |
run: | | |
Add-Type -assembly 'System.IO.Compression' | |
Add-Type -assembly 'System.IO.Compression.FileSystem' | |
[System.IO.Compression.ZipArchive]$zipFile = [System.IO.Compression.ZipFile]::Open('${{needs.build.outputs.zip-filename}}', ([System.IO.Compression.ZipArchiveMode]::Create)) | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'LICENSE', '${{needs.build.outputs.project-name}}\LICENSE') | |
$filesToZip = (Get-ChildItem -Path artifact -File -Recurse).FullName | |
foreach ($fileToZip in $filesToZip) { | |
$fileNameInZip = $fileToZip.Replace(($pwd.Path + '\artifact\'),'') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, $fileToZip, ('${{needs.build.outputs.project-name}}\' + $fileNameInZip)) | |
} | |
$zipFile.Dispose() | |
# Pushes the release | |
- name: Publish release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "latest${{inputs.releaseTypeTag}}" | |
prerelease: ${{env.is-prerelease}} | |
title: "Manual Build - ${{needs.build.outputs.version}} Release" | |
files: | | |
${{needs.build.outputs.zip-filename}} |