Skip to content

Commit

Permalink
Update dotnet-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Falcion authored Apr 22, 2024
1 parent 5c48a38 commit 7978fa8
Showing 1 changed file with 4 additions and 74 deletions.
78 changes: 4 additions & 74 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
name: publish
on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
- 'development'
release:
types:
- published

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget

defaults:
run:
shell: pwsh

jobs:
create_nuget:
runs-on: ubuntu-latest
Expand All @@ -31,8 +8,11 @@ jobs:

- name: Setup .NET
uses: actions/setup-dotnet@v4
- run: dotnet build --configuration Release --output ${{ env.NuGetDirectory }}

- name: Build project
run: dotnet build --configuration Release
working-directory: './source'

- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
working-directory: './source'

Expand All @@ -42,53 +22,3 @@ jobs:
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg

validate_nuget:
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4

- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}

- name: Install nuget validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
working-directory: './source'

- name: Validate package
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
working-directory: './source'

run_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Run tests
run: dotnet test --configuration Release
working-directory: './source'

deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ validate_nuget, run_test ]
steps:
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}

- name: Setup .NET Core
uses: actions/setup-dotnet@v4

- name: Publish NuGet package
run: |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
working-directory: './source'

0 comments on commit 7978fa8

Please sign in to comment.