Skip to content

Publish

Publish #6

Workflow file for this run

# 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:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- 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
echo "semver=$semver" >> $env:$GITHUB_OUTPUT
echo "version=$version" >> $env:$GITHUB_OUTPUT
echo "tag=v$semver" >> $env:$GITHUB_OUTPUT
- name: Display Version and Tag
shell: pwsh
run: |
echo "Version (Assembly): ${{ steps.extract-version.outputs.version }}"
echo "Version (SemVer): ${{ steps.extract-version.outputs.semver }}"
echo "Tag: ${{ steps.extract-version.outputs.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