From 6200e9cc894ce951c55245d69b86fa942111341f Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 31 Jan 2023 14:39:44 +0100 Subject: [PATCH] ci: add build and nuget push ci --- .github/workflows/build-test.yml | 41 +++++++++++++++++++ .github/workflows/nuget-push.yml | 31 ++++++++++++++ Directory.Build.props | 6 +++ NosSmooth.Comms.sln | 5 +++ .../NosSmooth.Comms.Abstractions.csproj | 2 - .../NosSmooth.Comms.Core.csproj | 2 - .../NosSmooth.Comms.Inject.csproj | 2 - .../NosSmooth.Comms.Local.csproj | 2 - 8 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/nuget-push.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..8df277b --- /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 NosSmooth.Comms.sln + - name: Build + run: dotnet build NosSmooth.Comms.sln --no-restore --version-suffix "main$GITHUB_RUN_ID" + - name: Test + run: dotnet test NosSmooth.Comms.sln --no-build --verbosity normal + + - name: Pack app + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: dotnet pack NosSmooth.Comms.sln -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 0000000..429077c --- /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.Comms.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/Directory.Build.props b/Directory.Build.props index 089e6a4..866b67e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,12 @@ $(StyleCopRuleset) + + + https://github.com/Rutherther/NosSmooth.Comms + main + https://github.com/Rutherther/NosSmooth.Comms + diff --git a/NosSmooth.Comms.sln b/NosSmooth.Comms.sln index 8534f62..7422c1e 100644 --- a/NosSmooth.Comms.sln +++ b/NosSmooth.Comms.sln @@ -16,6 +16,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsolePacketLogger", "src\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.Comms.Core", "src\Core\NosSmooth.Comms.Core\NosSmooth.Comms.Core.csproj", "{70275C91-1114-4673-8F9B-B0C311BFE337}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".metadata", ".metadata", "{EB208A2A-0F43-4573-8DE7-2F413DE4E5D9}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj b/src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj index 197e2fa..a3e4909 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj +++ b/src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj @@ -5,8 +5,6 @@ enable enable NosSmooth.Comms.Data - https://github.com/Rutherther/NosSmooth.Comms/ - MIT 1.0.0 diff --git a/src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj b/src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj index cfc5eb1..f084331 100644 --- a/src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj +++ b/src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj @@ -4,8 +4,6 @@ net7.0 enable enable - https://github.com/Rutherther/NosSmooth.Comms/ - MIT 1.0.0 diff --git a/src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj b/src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj index 638cad3..f2a5455 100644 --- a/src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj +++ b/src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj @@ -6,8 +6,6 @@ enable true true - https://github.com/Rutherther/NosSmooth.Comms/ - MIT 1.0.0 diff --git a/src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj b/src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj index 8d16324..4039904 100644 --- a/src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj +++ b/src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj @@ -4,8 +4,6 @@ net7.0 enable enable - https://github.com/Rutherther/NosSmooth.Comms/ - MIT 1.0.0 -- 2.48.1