From ed6c3026c9284e61fc1330106304ab8476a89bf9 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Fri, 21 Jul 2023 10:39:51 +0200 Subject: [PATCH] Split workflows for reuse --- .github/workflows/build-test-linux.yml | 33 ++++++++++++++ .github/workflows/build-test-win.yml | 34 +++++++++++++++ .github/workflows/dotnet-release.yml | 42 +++++++++--------- .github/workflows/dotnet.yml | 59 ++------------------------ Castle.Windsor.sln | 2 + 5 files changed, 94 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/build-test-linux.yml create mode 100644 .github/workflows/build-test-win.yml diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml new file mode 100644 index 000000000..75cb0f9bf --- /dev/null +++ b/.github/workflows/build-test-linux.yml @@ -0,0 +1,33 @@ +name: Build and test on linux + +on: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # Building requires an up-to-date .NET SDK. + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 7.0.x + + # Restore and build + - name: Restore dependencies + run: dotnet restore + - name: Build Nuget Versions + run: dotnet build ./tools/Explicit.NuGet.Versions/Explicit.NuGet.Versions.sln + - name: Build Release + run: dotnet build Castle.Windsor.sln -c Release + + # Run tests for linux + - name: Test on .NET 6.0 + run: | + dotnet test src/Castle.Windsor.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" \ No newline at end of file diff --git a/.github/workflows/build-test-win.yml b/.github/workflows/build-test-win.yml new file mode 100644 index 000000000..94391a0b9 --- /dev/null +++ b/.github/workflows/build-test-win.yml @@ -0,0 +1,34 @@ +name: Build and test on Windows + +on: + workflow_call: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + + # Building requires an up-to-date .NET SDK. + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 7.0.x + + # Restore and build + - name: Restore dependencies + run: dotnet restore + - name: Build Release + run: dotnet build Castle.Windsor.sln -c Release + + # Run tests on windows + - name: Test on .NET Framework 4.6.2 (Windows only) + run: | + dotnet test src/Castle.Windsor.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" + dotnet test src/Castle.Facilities.AspNet.Mvc.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" + dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" + dotnet test src/Castle.Facilities.AspNet.WebApi.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" + dotnet test src/Castle.Facilities.WcfIntegration.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" \ No newline at end of file diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 6d773e142..a801878be 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -6,38 +6,38 @@ on: - 'v*.*.*' jobs: - build-ubuntu: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup .NET 7.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 7.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build Release - run: dotnet build Castle.Windsor.sln -c Release - - name: Test on .NET 6.0 - run: dotnet test -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + build-lin: + name: Build and test Linux + uses: ./.github/workflows/build-test-linux.yml + + build-win: + name: Build and test on Windows + uses: ./.github/workflows/build-test-win.yml deploy: - needs: build-ubuntu + needs: [build-lin, build-win] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v3 + + # Building requires an up-to-date .NET SDK. + - name: Setup dotnet + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: | + 6.0.x + 7.0.x + - name: Restore dependencies run: dotnet restore - name: Get the version id: get_version run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d "v" -f 2) + - name: Build run: dotnet build Castle.Windsor.sln --configuration Release - name: Pack - run: dotnet pack Castle.Windsor.sln -c Release -o ./artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + run: dotnet pack Castle.Windsor.sln -c Release -o artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + - name: Push generated Rebus package to GitHub registry - run: dotnet nuget push /home/runner/work/Windsor/Windsor/artifacts/Castle.Windsor.${{ steps.get_version.outputs.VERSION }}.nupkg -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file + run: dotnet nuget push artifacts -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 118bdefe3..250e6544e 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -7,61 +7,10 @@ on: - '**.md' jobs: - build: + build-lin: name: Build and test Linux - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - # Building requires an up-to-date .NET SDK. - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 6.0.x - 7.0.x - - # Restore and build - - name: Restore dependencies - run: dotnet restore - - name: Build Nuget Versions - run: dotnet build ./tools/Explicit.NuGet.Versions/Explicit.NuGet.Versions.sln - - name: Build Release - run: dotnet build Castle.Windsor.sln -c Release - - # Run tests for linux - - name: Test on .NET 6.0 - run: | - dotnet test src/Castle.Windsor.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" - dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + uses: ./.github/workflows/build-test-linux.yml - test-windows: + build-win: name: Build and test on Windows - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - # Building requires an up-to-date .NET SDK. - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 6.0.x - 7.0.x - - # Restore and build - - name: Restore dependencies - run: dotnet restore - - name: Build Release - run: dotnet build Castle.Windsor.sln -c Release - - # Run tests on windows - - name: Test on .NET Framework 4.6.2 (Windows only) - run: | - dotnet test src/Castle.Windsor.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" - dotnet test src/Castle.Facilities.AspNet.Mvc.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" - dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" - dotnet test src/Castle.Facilities.AspNet.WebApi.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" - dotnet test src/Castle.Facilities.WcfIntegration.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed" + uses: ./.github/workflows/build-test-win.yml diff --git a/Castle.Windsor.sln b/Castle.Windsor.sln index f5c2203e3..d438cb73f 100644 --- a/Castle.Windsor.sln +++ b/Castle.Windsor.sln @@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Castle Build", "Castle Buil .gitattributes = .gitattributes .gitignore = .gitignore appveyor.yml = appveyor.yml + .github\workflows\build-test-linux.yml = .github\workflows\build-test-linux.yml + .github\workflows\build-test-win.yml = .github\workflows\build-test-win.yml build.cmd = build.cmd CHANGELOG.md = CHANGELOG.md CONTRIBUTING.md = CONTRIBUTING.md