Skip to content

v1.5

v1.5 #9

name: Build and Release
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --configuration Release --no-restore
- name: Publish application
run: dotnet publish -c Release -r win-x64 --self-contained false -o publish
- name: Compress artifacts
run: |
Compress-Archive -Path publish\* -DestinationPath HeavenTool-Windows.zip
shell: pwsh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: HeavenTool-Windows
path: HeavenTool-Windows.zip
- name: Extract version from project file
id: get_version
shell: pwsh
run: |
$projectPath = "Heaven Tool.csproj"
if (-Not (Test-Path $projectPath)) {
Write-Error "Project file not found: $projectPath"
exit 1
}
[xml]$projXml = Get-Content $projectPath
$versionNode = $projXml.SelectSingleNode("//Version")
if ($versionNode -and $versionNode.InnerText) {
$version = $versionNode.InnerText.Trim()
Write-Output "Found version: $version"
echo "version=$version" >> $env:GITHUB_OUTPUT
} else {
Write-Error "Version element not found or empty in $projectPath"
}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: HeavenTool-Windows
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ needs.build.outputs.version }}.${{ github.run_number }}"
release_name: "(Automatic) Release v${{ needs.build.outputs.version }} | Build ${{ github.run_number }}"
body: "Automated release for commit ${{ github.sha }} with version v${{ needs.build.outputs.version }}"
draft: false
prerelease: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./HeavenTool-Windows.zip
asset_name: HeavenTool-Windows.zip
asset_content_type: application/zip