Skip to content

Missing files

Missing files #59

name: Build Artefacts and Publish
on:
pull_request:
workflow_dispatch:
inputs:
publishToNuGet:
description: 'Publish to NuGet (y/n)'
required: true
default: 'n'
push:
branches:
- main
paths:
- 'Source/**/PackageVersion.txt'
env:
NuGetDirectory: ${{ github.workspace }}/nuget
NuGetPublishEnabled: true
jobs:
build-tools:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./Source
shell: pwsh
strategy:
matrix:
project:
- "Mdk.CheckDotNet/Mdk.CheckDotNet.csproj"
- "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 -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/**/*
build-primary:
runs-on: ubuntu-latest
environment: Deploy
needs:
- build-tools
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
- 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
- name: Restore dependencies
run: dotnet restore MDK-Packages.sln
- name: Build solution
run: dotnet build MDK-Packages.sln --configuration Release
- 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 }}
}
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
- name: Publish NuGet packages
if: ${{ env.NuGetPublishEnabled == 'true' && ((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
}