Skip to content

Commit

Permalink
Add pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterOrneholm committed Apr 7, 2024
1 parent 86dc3ec commit ff4c97a
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Build and Publish to NuGet

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- '*'
release:
types:
- published # Run the workflow when a new GitHub release is published

jobs:
build-and-test:
Expand All @@ -24,9 +31,7 @@ jobs:
- uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
global-json-file: 'global.json' # assuming you're using a global.json
uses: actions/setup-dotnet@v4

- name: Restore dependencies
run: dotnet restore ${{ github.workspace }}/**/*.csproj --verbosity Detailed
Expand All @@ -43,7 +48,7 @@ jobs:
- name: Pack Release
run: dotnet pack ${{ github.workspace }}/**/src/**/*.csproj --output ${{ github.workspace }}/artifacts/release --configuration Release --verbosity Detailed

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifactName }}
path: ${{ github.workspace }}/artifacts/
Expand All @@ -66,14 +71,30 @@ jobs:
- uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
global-json-file: 'global.json' # if you're using a global.json
uses: actions/setup-dotnet@v4

- name: Publish Samples
run: dotnet publish ${{ github.workspace }}/**/samples/**/*.csproj --configuration Release --output ${{ github.workspace }}/samples/

- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifactName }}
path: ${{ github.workspace }}/samples/
path: ${{ github.workspace }}/samples/
deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ build-and-test, build-samples ]
steps:
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ github.workspace }}/artifacts/

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

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

0 comments on commit ff4c97a

Please sign in to comment.