Better messagebox title #36
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: Build Artefacts and Publish | |
on: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
publishToNuGet: | |
description: 'Publish to NuGet (y/n)' | |
required: true | |
default: 'n' | |
push: | |
branches: | |
- dotnet9 | |
paths: | |
- 'Source/**/PackageVersion.txt' | |
env: | |
NuGetDirectory: ${{ github.workspace }}/nuget | |
NuGetPublishEnabled: false | |
jobs: | |
# Job to build individual tool projects | |
build-dependent: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./Source | |
shell: pwsh | |
strategy: | |
matrix: | |
project: | |
- "Mdk.CommandLine/Mdk.CommandLine.csproj" | |
- "Mdk.Notification.Windows/Mdk.Notification.Windows.csproj" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.x | |
- name: Build tool project | |
run: | | |
dotnet publish ${{ matrix.project }} -c Release -o ../output --self-contained true -r win-x64 -p:DebugType=None | |
- name: Prepare artifact name | |
run: | | |
$outputDir = "../output" | |
$exePath = Get-ChildItem $outputDir -Filter *.exe | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | |
if (-not $exePath) { | |
Write-Error "No executable found in output directory!" | |
exit 1 | |
} | |
Write-Host "Generated executable: $exePath" | |
$artifactName = $exePath.BaseName | |
Write-Host "Artifact name: $artifactName" | |
echo "ARTIFACT_NAME=$artifactName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 | |
- name: Debug artifact name | |
run: | | |
echo "ARTIFACT_NAME is: ${{ env.ARTIFACT_NAME }}" | |
- name: Upload tool artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-artifact | |
if-no-files-found: error | |
retention-days: 7 | |
path: ./output/**/* | |
# Job to build individual tool projects | |
build-self-contained: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./Source | |
shell: pwsh | |
strategy: | |
matrix: | |
project: | |
- "Mdk.CheckDotNet/Mdk.CheckDotNet.csproj" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.x | |
- name: Build tool project | |
run: | | |
dotnet publish ${{ matrix.project }} -c Release -o ../output --self-contained true -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None | |
- name: Prepare artifact name | |
run: | | |
$outputDir = "../output" | |
$exePath = Get-ChildItem $outputDir -Filter *.exe | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | |
if (-not $exePath) { | |
Write-Error "No executable found in output directory!" | |
exit 1 | |
} | |
Write-Host "Generated executable: $exePath" | |
$artifactName = $exePath.BaseName | |
Write-Host "Artifact name: $artifactName" | |
echo "ARTIFACT_NAME=$artifactName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 | |
- name: Debug artifact name | |
run: | | |
echo "ARTIFACT_NAME is: ${{ env.ARTIFACT_NAME }}" | |
- name: Upload tool artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-artifact | |
if-no-files-found: error | |
retention-days: 7 | |
path: ./output/**/* | |
# Job to build the primary project | |
build-primary: | |
runs-on: ubuntu-latest | |
needs: | |
- build-dependent | |
- build-self-contained | |
defaults: | |
run: | |
working-directory: ./Source | |
shell: pwsh | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.x | |
# Download artifacts from the tool projects | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: mdk-artifact | |
path: ./Source/Mdk.PbPackager/tools | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: mdknotify-win-artifact | |
path: ./Source/Mdk.PbPackager/tools | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: checkdotnet-artifact | |
path: ./Source/Mdk.PbPackager/tools | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: mdk-artifact | |
path: ./Source/Mdk.ModPackager/tools | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: mdknotify-win-artifact | |
path: ./Source/Mdk.ModPackager/tools | |
- name: Download tool artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: checkdotnet-artifact | |
path: ./Source/Mdk.ModPackager/tools | |
# Restore dependencies for the whole solution | |
- name: Restore dependencies | |
run: dotnet restore MDK-Packages.sln | |
# Build the primary solution | |
- name: Build solution | |
run: dotnet build MDK-Packages.sln --configuration Release | |
# Collect NuGet packages | |
- name: Collect NuGet packages | |
run: | | |
New-Item -ItemType Directory -Force -Path ${{ env.NuGetDirectory }} | |
$files = Get-ChildItem -Path . -Filter *.nupkg -Recurse | |
Write-Host "Found files: $files" | |
foreach ($file in $files) { | |
Write-Host "Copying file: $file" | |
Copy-Item -Path $file.FullName -Destination ${{ env.NuGetDirectory }} | |
} | |
# Upload NuGet packages as an artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nuget | |
if-no-files-found: error | |
retention-days: 7 | |
path: ${{ env.NuGetDirectory }}/*.nupkg | |
# Publish NuGet packages to NuGet.org | |
- name: Publish NuGet packages | |
if: ${{ (env.NuGetPublishEnabled) && ((github.event_name == 'workflow_dispatch' && github.event.inputs.publishToNuGet == 'y') || github.event_name == 'push') }} | |
run: | | |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { | |
dotnet nuget push $file --api-key "${{ secrets.NUGET_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
} | |