-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e71e31f
commit b991ca9
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# This workflow will build a .NET project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | ||
|
||
name: Build and Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
publishToNuGet: | ||
description: 'Publish to NuGet (y/n)' | ||
required: true | ||
default: 'y' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'Source/**/PackageVersion.txt' | ||
|
||
env: | ||
NuGetDirectory: ${{ github.workspace }}/nuget | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
environment: Deploy | ||
|
||
defaults: | ||
run: | ||
working-directory: ./Source | ||
shell: pwsh | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build solution | ||
run: dotnet build --configuration Release | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: BuildOutput | ||
retention-days: 7 | ||
path: "**/bin/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@v3 | ||
with: | ||
name: nuget | ||
if-no-files-found: error | ||
retention-days: 7 | ||
path: ${{ env.NuGetDirectory }}/*.nupkg | ||
|
||
- name: Publish NuGet packages | ||
if: ${{ (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 | ||
} |