Update dotnet-desktop.yml #124
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: VXMusic Desktop Build/Release | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: # Add this to manually trigger the workflow | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7.x' | |
- name: Get Project Version | |
uses: kzrnm/get-net-sdk-project-versions-action@v2 | |
id: get-project-version | |
with: | |
proj-path: VXMusicDesktop/VXMusicDesktop.csproj | |
# - name: Get Last Tag Version | |
# id: previoustag | |
# uses: 'WyriHaximus/github-action-get-previous-tag@v1' | |
# with: | |
# fallback: ${{ steps.get-project-version.outputs.version }} | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Determine next version | |
# id: nextversion | |
# run: | | |
# $current_version = '${{ steps.previoustag.outputs.tag }}' | |
# $base_version = '${{ steps.get-project-version.outputs.version }}' | |
# if ($current_version -match '(\d+)\.(\d+)\.(\d+)') { | |
# $major = [int]$matches[1] | |
# $minor = [int]$matches[2] | |
# $patch = [int]$matches[3] + 1 | |
# $new_version = "$major.$minor.$patch" | |
# } else { | |
# $new_version = "$base_version.0" | |
# } | |
# echo "VERSION=$new_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 | |
# shell: pwsh | |
# - name: Set New Version | |
# id: set_project_version | |
# run: | | |
# $new_version = ${{ steps.get-project-version.outputs.version }} | |
# echo "Dynamic Version: $new_version" | |
# echo "new_version=$new_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 | |
# shell: pwsh | |
# - name: Update CSPROJ with dynamic version | |
# run: | | |
# $csproj_path = "VXMusicDesktop/VXMusicDesktop.csproj" | |
# $new_version = $env:new_version | |
# (Get-Content $csproj_path) -replace '<Version>.*</Version>', "<Version>$new_version</Version>" | Set-Content $csproj_path | |
# shell: pwsh | |
- name: Replace version in NSIS script | |
run: | | |
(Get-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi") -replace '(!define PRODUCT_VERSION ").*(")', '"${{ steps.get-project-version.outputs.version }}"' | Set-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi" | |
Get-Content -path "${{ github.workspace }}/Installer/VXMusic.nsi" | |
shell: pwsh | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build solution | |
run: dotnet build --configuration Release --no-restore | |
- name: Publish VXMusic | |
run: dotnet publish ${{ github.workspace }}/VXMusicDesktop/VXMusicDesktop.csproj -r win-x64 -c Release -o ${{ github.workspace }}/Publish/x64 | |
- name: Package VXMusic | |
run: | | |
cd ${{ github.workspace }}/Publish/x64 | |
Compress-Archive -Path * -DestinationPath ../../VXMusic_x64_v${{ steps.get-project-version.outputs.version }}.zip | |
shell: pwsh | |
- name: makensis | |
uses: joncloud/[email protected] | |
with: | |
script-file: "${{ github.workspace }}/Installer/VXMusic.nsi" | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.get-project-version.outputs.version }} | |
release_name: VXMusic Release v${{ steps.get-project-version.outputs.version }} | |
draft: true | |
prerelease: false | |
- name: Upload Installer Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}/Installer/VXMusicInstaller.exe | |
asset_name: VXMusicInstaller_${{ steps.get-project-version.outputs.version }}.exe | |
asset_content_type: application/octet-stream | |
- 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: ${{ github.workspace }}/VXMusic_x64_v${{ steps.get-project-version.outputs.version }}.zip | |
asset_name: VXMusic_x64_v${{ steps.get-project-version.outputs.version }}.zip | |
asset_content_type: application/zip |