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 0000000000000000000000000000000000000000..8df277b728a92246bf9aae16f93afe43ddc6dc35 --- /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 0000000000000000000000000000000000000000..429077c62b572027b1834ea2815f5b3041059e2c --- /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 089e6a4c193f3d679664f1be79ee729d8da969e4..866b67e29e66ee6eaf175a6f6437c5e88abb87a9 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 8534f626514b3e2c253b9c8010e4eeb8c9a2fdac..7422c1e68db8bd922ea22a32cb884fd0de71547c 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 197e2faa8a56365c92b1fc4c90415751476255bd..a3e4909eed49e2451a6d27a8b3d5d175d670d65a 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 cfc5eb18aedb4a52aac58ebfd1cfab5d85fbf474..f084331d2cbe0932845930b3fd722fa4e54dc4a9 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 638cad3fd20dac121904177c5622a0d20afd0433..f2a5455d6e77e64d45365a9a05dd2b264de06834 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 8d1632464e5af10ac956d2a3cd7668fde5837d30..403990433b597e1432a63333a50a6429d979ca1c 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