Skip to content

Commit

Permalink
Split workflows for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Jul 21, 2023
1 parent 4f778ff commit ed6c302
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 76 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-test-linux.yml
Original file line number Diff line number Diff line change
@@ -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"
34 changes: 34 additions & 0 deletions .github/workflows/build-test-win.yml
Original file line number Diff line number Diff line change
@@ -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"
42 changes: 21 additions & 21 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run: dotnet nuget push artifacts -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
59 changes: 4 additions & 55 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions Castle.Windsor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed6c302

Please sign in to comment.