Publish #17
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: "Create a draft release?" | |
required: false | |
type: boolean | |
default: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show Inputs | |
run: echo "${{ toJSON(github.event.inputs) }}" | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: | | |
dotnet restore --packages .nuget --runtime win-x64 | |
- name: Extract Version from Project File | |
id: extract-version | |
shell: pwsh | |
run: | | |
$csprojPath = (Get-ChildItem -Path . -Recurse -Filter *.csproj).FullName | |
$version = [xml](Get-Content $csprojPath) | Select-Xml -XPath "//PropertyGroup/AssemblyVersion" | ForEach-Object { $_.Node.InnerXml } | |
if (-not $version) { | |
$version = [xml](Get-Content $csprojPath) | Select-Xml -XPath "//PropertyGroup/Version" | ForEach-Object { $_.Node.InnerXml } | |
} | |
$semver = $version -replace '(\d+\.\d+\.\d+)\.\d+', '$1' # Convert to semver by stripping the 4th part | |
$tag="v$semver" | |
echo "version = $version" | |
echo "semver = $semver" | |
echo "tag = $tag" | |
echo "rawVersion=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 | |
echo "semverVersion=$semver" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 | |
echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 | |
- name: Display Version and Tag | |
shell: pwsh | |
run: | | |
$version = '${{ steps.extract-version.outputs.rawVersion }}' | |
$semver = '${{ steps.extract-version.outputs.semverVersion }}' | |
$tag = '${{ steps.extract-version.outputs.tag }}' | |
Write-Host "Version: $version" | |
Write-Host "SemVer: $semver" | |
Write-Host "Tag: $tag" | |
- name: Build | |
run: | | |
dotnet build --configuration Release --no-restore | |
- name: Publish | |
run: | | |
dotnet publish -c Release -r win-x64 | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
# name: # optional, default is artifact | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ github.workspace }}/bin/Release/net8.0/win-x64/publish/**/* | |
# The desired behavior if no files are found using the provided path. | |
# if-no-files-found: # optional, default is warn | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ inputs.release == true }} | |
with: | |
files: ${{ github.workspace }}/bin/Release/net8.0/win-x64/publish/**/* | |
prerelease: true | |
draft: true | |
name: ${{ steps.extract-version.outputs.SEMVER }} | |
tag_name: ${{ steps.extract-version.outputs.TAG }} |