Skip to content

Manual Release - Develop #33

Manual Release - Develop

Manual Release - Develop #33

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"
strategy:
matrix:
publish-profile-name: [x86, x64]
env:
working-directory: .
project-name: SRTHost
platform: ${{matrix.publish-profile-name}}
outputs:
project-name: ${{env.project-name}}
solution: ${{steps.generated-variables-1.outputs.solution}}
project: ${{steps.generated-variables-1.outputs.project}}
publish-directory: ${{steps.generated-variables-1.outputs.publish-directory}}
version: ${{steps.project-version-string.outputs.Version}}
steps:
# Create repo user folder for the dependencies
- name: Create repo user folder
run: New-Item -ItemType directory -Path ..\..\SpeedRunTool
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: develop
path: ${{env.project-name}}
# Checkout latest dependencies code
- name: Checkout SRTPluginBase
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: develop
path: SRTPluginBase
repository: SpeedRunTool/SRTPluginBase
- name: Set the main environment variables based on other environment variables
id: generated-variables-1
run: |
echo 'solution=${{env.project-name}}/${{env.project-name}}.sln' >> $env:GITHUB_OUTPUT
echo 'project=${{env.project-name}}/src/${{env.project-name}}/${{env.project-name}}.csproj' >> $env:GITHUB_OUTPUT
echo 'publish-directory=${{env.project-name}}/src/${{env.project-name}}/bin/${{inputs.buildConfig}}/net7.0-windows/publish/' >> $env:GITHUB_OUTPUT
- 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
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-quality: 'ga'
- name: Restore
run: dotnet restore ${{steps.generated-variables-1.outputs.solution}} /p:"Configuration=${{inputs.buildConfig}};Platform=$env:platform" --verbosity normal
#- name: Build
# run: dotnet build ${{steps.generated-variables-1.outputs.solution}} /p:"Configuration=${{inputs.buildConfig}};Platform=$env:platform" --no-restore --verbosity normal
#- name: Unit tests
# run: dotnet test ${{steps.generated-variables-1.outputs.solution}} --no-restore --no-build --verbosity normal
- name: Publish
run: dotnet publish ${{steps.generated-variables-1.outputs.solution}} /p:"Configuration=${{inputs.buildConfig}};PublishProfile=${{matrix.publish-profile-name}}" --verbosity normal
- name: Upload publish artifacts
uses: actions/upload-artifact@v3
with:
path: |
${{steps.generated-variables-1.outputs.publish-directory}}*
setup:
name: "Setup"
runs-on: "windows-latest"
needs: build
env:
working-directory: .
is-prerelease: true
steps:
# Checkout latest code
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: develop
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Sets the setup-filename environment variable based on the project version
id: generated-variables-1
run: |
echo 'setup-filename=${{needs.build.outputs.project-name}}Setup-v${{needs.build.outputs.version}}.exe' >> $env:GITHUB_OUTPUT
# Decode the base 64 encoded pfx and save the code signing certificate
- 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'
- name: Code sign the program
run: |
$filesToSign = (Get-ChildItem -Path 'artifact/' -Filter SRTHost*.exe).fullname
foreach ($fileToSign in $filesToSign) {
& "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA1 "$fileToSign"
& "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA256 /as "$fileToSign"
& "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA512 /as "$fileToSign"
}
- name: Download NetCoreCheck Latest
run: |
./src/SRTHostSetup/DownloadNetCoreCheckLatest.ps1
Move-Item -Path .\NetCoreCheck_*.exe -Destination src/SRTHostSetup
- name: Create setup
run: ."${Env:ProgramFiles(x86)}/Inno Setup 6/ISCC.exe" "/DVersionTag=${{needs.build.outputs.version}}" "src/SRTHostSetup/SRTHostSetup.iss"
- name: Code sign the setup
run: |
."C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA1 "src/SRTHostSetup/Output/${{steps.generated-variables-1.outputs.setup-filename}}"
."C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA256 /as "src/SRTHostSetup/Output/${{steps.generated-variables-1.outputs.setup-filename}}"
."C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe" sign /tr "http://timestamp.digicert.com" /td SHA1 /f "CodeSign.pfx" /p "${{secrets.CODE_SIGN_CERTIFICATE_PASS}}" /fd SHA512 /as "src/SRTHostSetup/Output/${{steps.generated-variables-1.outputs.setup-filename}}"
- name: Publish setup
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "develop-build"
prerelease: ${{env.is-prerelease}}
title: 'Manual Build [develop] - ${{needs.build.outputs.version}} Release'
files: |
src/SRTHostSetup/Output/${{steps.generated-variables-1.outputs.setup-filename}}