ensure publish folder exists #4
Workflow file for this run
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: Release with Tag Version | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Match version tags like v1.0.0 | |
jobs: | |
release: | |
runs-on: windows-latest # Use a Windows runner | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Extract version from tag | |
run: echo "VERSION=${GITHUB_REF_NAME#refs/tags/v}" >> $GITHUB_ENV | |
- name: Extract publish directory from profile | |
run: | | |
$publishProfilePath = "CsvConverter/Properties/PublishProfiles/FolderProfile.pubxml" | |
$publishDir = (Select-Xml -Path $publishProfilePath -XPath "//PublishDir").Node.InnerText | |
echo "PUBLISH_DIR=$publishDir" >> $GITHUB_ENV | |
shell: pwsh | |
- name: Update version in .csproj | |
run: | | |
echo "Updating version in .csproj to ${VERSION}" | |
powershell -Command "(Get-Content CsvConverter/CsvConverter.csproj) -replace '<Version>.*</Version>', '<Version>${VERSION}</Version>' | Set-Content CsvConverter/CsvConverter.csproj" | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Publish application using publish profile | |
run: dotnet publish CsvConverter/CsvConverter.csproj -c Release /p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml | |
- name: Verify publish output | |
run: | | |
if (!(Test-Path -Path "${{ env.PUBLISH_DIR }}")) { | |
Write-Error "Publish directory does not exist: ${{ env.PUBLISH_DIR }}" | |
exit 1 | |
} | |
Write-Host "Publish directory found: ${{ env.PUBLISH_DIR }}" | |
- name: Archive published binaries | |
run: | | |
mkdir release | |
powershell Compress-Archive -Path "${{ env.PUBLISH_DIR }}\*" -DestinationPath "release\CsvConverter-${{ env.VERSION }}.zip" | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
files: release\CsvConverter-${{ env.VERSION }}.zip |