From 1157aa3e8ba9b2f9ee930fb4a7408636a13a1fdb Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 21 Jan 2023 21:33:42 +0100 Subject: [PATCH] ci: add nuget and myget support --- .github/workflows/build-test.yml | 41 +++++++++++++++++++++++++++++++ .github/workflows/nuget-push.yml | 31 +++++++++++++++++++++++ src/Samples/Directory.Build.props | 5 ++++ 3 files changed, 77 insertions(+) create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/nuget-push.yml create mode 100644 src/Samples/Directory.Build.props diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..e82f9b6914c664c4330980762f5864d46252e9e4 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,41 @@ +# 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: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 7.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore --version-suffix "main$GITHUB_RUN_ID" + - name: Test + run: dotnet test --no-build --verbosity normal + + - name: Pack app + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: dotnet pack -c Release --no-restore --version-suffix "main$GITHUB_RUN_ID" -o nuget + + - name: Publish NuGet on MyGet + working-directory: nuget + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: dotnet nuget push *.nupkg --skip-duplicate -k $MYGET_AUTH_TOKEN -s https://www.myget.org/F/nossmooth/api/v3/index.json + env: + MYGET_AUTH_TOKEN: ${{secrets.MYGET_KEY}} \ No newline at end of file diff --git a/.github/workflows/nuget-push.yml b/.github/workflows/nuget-push.yml new file mode 100644 index 0000000000000000000000000000000000000000..75d9232128ab4b9fde94614adc761634ed2df932 --- /dev/null +++ b/.github/workflows/nuget-push.yml @@ -0,0 +1,31 @@ +# This workflow pushes builds to the private github nuget repo on a push or merge. + +name: NuGet Update + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + name: Update NuGet Package + steps: + + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '7.0.x' + + - name: Pack app + run: dotnet pack NosSmooth.Local.sln --configuration Release -o nuget + + - name: Publish NuGet + working-directory: nuget + run: dotnet nuget push *.nupkg --skip-duplicate -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.NUGET_KEY}} diff --git a/src/Samples/Directory.Build.props b/src/Samples/Directory.Build.props new file mode 100644 index 0000000000000000000000000000000000000000..63cf3db7c8db7f950f7773159b7d6684aa6cc339 --- /dev/null +++ b/src/Samples/Directory.Build.props @@ -0,0 +1,5 @@ + + + false + +