Skip to content

Commit

Permalink
Refactor workflow for less repetition (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
colindembovsky authored Mar 25, 2022
1 parent adcc467 commit 264d3b9
Showing 1 changed file with 37 additions and 84 deletions.
121 changes: 37 additions & 84 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
name: publish nuget
name: publish nuget matrix
on:
push:
tags:
- 1.*

jobs:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Test
run: dotnet test

publish:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
project:
- Blazor.SourceGenerators
- Blazor.Serialization
- Blazor.LocalStorage.WebAssembly
- Blazor.LocalStorage.Server
- Blazor.SessionStorage.WebAssembly
- Blazor.SessionStorage.Server
- Blazor.Geolocation.WebAssembly
- Blazor.Geolocation.Server
steps:

- name: Print tag ref
Expand All @@ -28,90 +51,20 @@ jobs:
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: |
dotnet restore ./src/Blazor.SourceGenerators/Blazor.SourceGenerators.csproj
dotnet restore ./src/Blazor.Serialization/Blazor.Serialization.csproj
dotnet restore ./src/Blazor.LocalStorage.WebAssembly/Blazor.LocalStorage.WebAssembly.csproj
dotnet restore ./src/Blazor.LocalStorage.Server/Blazor.LocalStorage.Server.csproj
dotnet restore ./src/Blazor.SessionStorage.WebAssembly/Blazor.SessionStorage.WebAssembly.csproj
dotnet restore ./src/Blazor.SessionStorage.Server/Blazor.SessionStorage.Server.csproj
dotnet restore ./src/Blazor.Geolocation.WebAssembly/Blazor.Geolocation.WebAssembly.csproj
dotnet restore ./src/Blazor.Geolocation.Server/Blazor.Geolocation.Server.csproj
- name: Build
- name: Restore dependencies for ${{ matrix.project }}
run: |
dotnet build ./src/Blazor.SourceGenerators/Blazor.SourceGenerators.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.Serialization/Blazor.Serialization.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.LocalStorage.WebAssembly/Blazor.LocalStorage.WebAssembly.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.LocalStorage.Server/Blazor.LocalStorage.Server.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.SessionStorage.WebAssembly/Blazor.SessionStorage.WebAssembly.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.SessionStorage.Server/Blazor.SessionStorage.Server.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.Geolocation.WebAssembly/Blazor.Geolocation.WebAssembly.csproj --configuration Release --no-restore
dotnet build ./src/Blazor.Geolocation.Server/Blazor.Geolocation.Server.csproj --configuration Release --no-restore
- name: Test
run: dotnet test
dotnet restore ./src/${{ matrix.project }}/${{ matrix.project }}.csproj
- name: Pack
run: |
dotnet pack ./src/Blazor.SourceGenerators/Blazor.SourceGenerators.csproj --output packages
dotnet pack ./src/Blazor.Serialization/Blazor.Serialization.csproj --output packages
dotnet pack ./src/Blazor.LocalStorage.WebAssembly/Blazor.LocalStorage.WebAssembly.csproj --output packages
dotnet pack ./src/Blazor.LocalStorage.Server/Blazor.LocalStorage.Server.csproj --output packages
dotnet pack ./src/Blazor.SessionStorage.WebAssembly/Blazor.SessionStorage.WebAssembly.csproj --output packages
dotnet pack ./src/Blazor.SessionStorage.Server/Blazor.SessionStorage.Server.csproj --output packages
dotnet pack ./src/Blazor.Geolocation.WebAssembly/Blazor.Geolocation.WebAssembly.csproj --output packages
dotnet pack ./src/Blazor.Geolocation.Server/Blazor.Geolocation.Server.csproj --output packages
- name: Publish package
- name: Build ${{ matrix.project }}
run: |
nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -NoSymbols -NonInteractive -ApiKey ${{secrets.NUGET_API_KEY}}
dotnet build ./src/${{ matrix.project }}/${{ matrix.project }}.csproj --configuration Release --no-restore
- name: Upload source generators package
uses: actions/upload-artifact@v2
- name: Upload ${{ matrix.project }}
uses: ./.github/workflows/upload-package
with:
name: Blazor.SourceGenerators.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload serialization package
uses: actions/upload-artifact@v2
with:
name: Blazor.Serialization.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload localStorage WebAssembly package
uses: actions/upload-artifact@v2
with:
name: Blazor.LocalStorage.WebAssembly.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload localStorage Server package
uses: actions/upload-artifact@v2
with:
name: Blazor.LocalStorage.Server.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload sessionStorage WebAssembly package
uses: actions/upload-artifact@v2
with:
name: Blazor.SessionStorage.WebAssembly.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload sessionStorage Server package
uses: actions/upload-artifact@v2
with:
name: Blazor.SessionStorage.Server.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload geolocation WebAssembly package
uses: actions/upload-artifact@v2
with:
name: Blazor.Geolocation.WebAssembly.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/

- name: Upload geolocation Server package
uses: actions/upload-artifact@v2
with:
name: Blazor.Geolocation.Server.${{ steps.regex-match.outputs.match }}.nupkg
path: packages/
version: ${{ steps.regex-match.outputs.match }}
project-name: ${{ matrix.project }}

- name: Publish ${{ matrix.project }} package
run: |
nuget push **\${{ matrix.project }}.*.nupkg -Source 'https://api.nuget.org/v3/index.json' -NoSymbols -NonInteractive -ApiKey ${{secrets.NUGET_API_KEY}}

0 comments on commit 264d3b9

Please sign in to comment.