Update version to 1.0.21 #22
Workflow file for this run
This file contains hidden or 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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version number (e.g., 1.0.3)' | |
| required: true | |
| type: string | |
| env: | |
| DOTNET_VERSION: '8.0.x' | |
| PROJECT_PATH: 'src/MouseEffects.App/MouseEffects.App.csproj' | |
| TARGET_FRAMEWORK: 'net8.0-windows10.0.19041.0' | |
| # Required for creating releases | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Determine version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| if ("${{ github.event.inputs.version }}" -ne "") { | |
| $version = "${{ github.event.inputs.version }}" | |
| } else { | |
| $version = "${{ github.ref_name }}".TrimStart('v') | |
| } | |
| echo "VERSION=$version" >> $env:GITHUB_OUTPUT | |
| echo "Version: $version" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| # ============================================================ | |
| # BUILD AND PUBLISH FOR x64 | |
| # ============================================================ | |
| - name: Build solution (x64) | |
| run: dotnet build --configuration Release --no-restore -p:Platform=x64 | |
| - name: Publish application (x64) | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} ` | |
| --configuration Release ` | |
| --runtime win-x64 ` | |
| --self-contained true ` | |
| --output ./publish/win-x64 ` | |
| -p:PublishSingleFile=false ` | |
| -p:Version=${{ steps.version.outputs.VERSION }} | |
| - name: Copy plugins (x64) | |
| shell: pwsh | |
| run: | | |
| $pluginsSource = "./src/MouseEffects.App/bin/x64/Release/${{ env.TARGET_FRAMEWORK }}/plugins" | |
| $pluginsDest = "./publish/win-x64/plugins" | |
| if (Test-Path $pluginsSource) { | |
| New-Item -ItemType Directory -Force -Path $pluginsDest | Out-Null | |
| Copy-Item -Path "$pluginsSource\*" -Destination $pluginsDest -Recurse -Force | |
| Write-Host "x64 plugins copied" | |
| } else { | |
| Write-Host "Warning: x64 plugins not found at $pluginsSource" | |
| } | |
| # ============================================================ | |
| # CREATE VELOPACK PACKAGE | |
| # ============================================================ | |
| - name: Install Velopack CLI | |
| run: dotnet tool install -g vpk | |
| - name: Create Velopack release (x64) | |
| shell: pwsh | |
| run: | | |
| vpk pack ` | |
| --packId MouseEffects ` | |
| --packVersion ${{ steps.version.outputs.VERSION }} ` | |
| --packDir ./publish/win-x64 ` | |
| --mainExe MouseEffects.App.exe ` | |
| --outputDir ./releases/x64 ` | |
| --packTitle "MouseEffects" ` | |
| --icon ./src/MouseEffects.App/MouseEffects.ico | |
| # ============================================================ | |
| # RENAME ARTIFACTS FOR CLARITY | |
| # ============================================================ | |
| - name: Rename artifacts | |
| shell: pwsh | |
| run: | | |
| $version = "${{ steps.version.outputs.VERSION }}" | |
| # Rename setup file to include architecture | |
| Move-Item -Path "./releases/x64/MouseEffects-win-Setup.exe" -Destination "./releases/MouseEffects-x64-Setup.exe" -Force | |
| # Rename nupkg files to include architecture | |
| Get-ChildItem -Path "./releases/x64/*.nupkg" | ForEach-Object { | |
| $newName = $_.Name -replace "-full\.nupkg$", "-x64-full.nupkg" | |
| Move-Item -Path $_.FullName -Destination "./releases/$newName" -Force | |
| } | |
| # Update RELEASES file content to match renamed nupkg files, then rename the file | |
| $releasesContent = Get-Content -Path "./releases/x64/RELEASES" -Raw | |
| $updatedContent = $releasesContent -replace "-full\.nupkg", "-x64-full.nupkg" | |
| Set-Content -Path "./releases/RELEASES-x64" -Value $updatedContent -NoNewline | |
| Remove-Item -Path "./releases/x64/RELEASES" -Force | |
| - name: List release artifacts | |
| shell: pwsh | |
| run: | | |
| echo "Release artifacts:" | |
| Get-ChildItem -Path ./releases -Recurse | Format-Table Name, Length | |
| # ============================================================ | |
| # UPLOAD AND RELEASE | |
| # ============================================================ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: MouseEffects-${{ steps.version.outputs.VERSION }} | |
| path: | | |
| ./releases/MouseEffects-x64-Setup.exe | |
| ./releases/*.nupkg | |
| ./releases/RELEASES-* | |
| retention-days: 30 | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: MouseEffects v${{ steps.version.outputs.VERSION }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| generate_release_notes: true | |
| files: | | |
| ./releases/MouseEffects-x64-Setup.exe | |
| ./releases/*-x64-full.nupkg | |
| ./releases/RELEASES-x64 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release (manual trigger) | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.VERSION }} | |
| name: MouseEffects v${{ steps.version.outputs.VERSION }} | |
| draft: true | |
| prerelease: false | |
| generate_release_notes: true | |
| files: | | |
| ./releases/MouseEffects-x64-Setup.exe | |
| ./releases/*-x64-full.nupkg | |
| ./releases/RELEASES-x64 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |