-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
135 lines (112 loc) · 4.07 KB
/
publish-templates.yml
File metadata and controls
135 lines (112 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Publish Templates to NuGet
on:
workflow_dispatch:
inputs:
publish-full:
description: 'Publish Full Clean Architecture Template'
required: true
type: boolean
default: false
publish-minimal:
description: 'Publish Minimal Clean Architecture Template'
required: true
type: boolean
default: false
push:
tags:
- 'v*'
release:
types: [published]
env:
DOTNET_VERSION: '10.0.x'
PACK_OUTPUT: artifacts/packages
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build Full Template Solution
run: dotnet build ./Clean.Architecture.slnx -c Release
- name: Test Full Template
run: dotnet test ./Clean.Architecture.slnx -c Release --no-build --verbosity normal
- name: Build MinimalClean Template Solution
run: dotnet build ./MinimalClean/MinimalClean.Architecture.slnx -c Release
- name: Test Template Installations
shell: pwsh
run: |
# Test Full Template
# Write-Host "Testing Full Clean Architecture Template..."
# dotnet new install .
# dotnet new clean-arch -o TestFullTemplate
# dotnet build TestFullTemplate/TestFullTemplate.slnx
# dotnet new uninstall Ardalis.CleanArchitecture.Template
# Remove-Item -Recurse -Force TestFullTemplate
# Test Minimal Template
# Write-Host "Testing Minimal Clean Architecture Template..."
# dotnet new install ./MinimalClean
# dotnet new min-clean -o TestMinimalTemplate
# dotnet build TestMinimalTemplate/TestMinimalTemplate.slnx
# dotnet new uninstall Ardalis.MinimalClean.Template
# Remove-Item -Recurse -Force TestMinimalTemplate
package:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-version: 'latest'
- name: Install Mono
run: sudo apt-get update && sudo apt-get install -y mono-complete
- name: Create output directory
run: mkdir -p ${{ env.PACK_OUTPUT }}
- name: Pack Full Template
if: ${{ github.event_name == 'release' || github.event.inputs.publish-full == 'true' }}
run: nuget pack CleanArchitecture.nuspec -OutputDirectory ${{ env.PACK_OUTPUT }} -NoDefaultExcludes
- name: Pack Minimal Template
if: ${{ github.event_name == 'release' || github.event.inputs.publish-minimal == 'true' }}
run: nuget pack MinimalClean.nuspec -OutputDirectory ${{ env.PACK_OUTPUT }} -NoDefaultExcludes
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ${{ env.PACK_OUTPUT }}/*.nupkg
publish:
needs: package
runs-on: ubuntu-latest
#if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
permissions:
contents: read
id-token: write
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ${{ env.PACK_OUTPUT }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: NuGet login (OIDC)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push packages to NuGet
shell: pwsh
run: |
Get-ChildItem "${{ env.PACK_OUTPUT }}" -Filter *.nupkg | ForEach-Object {
Write-Host "Publishing $($_.Name)..."
dotnet nuget push $_.FullName `
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" `
--source https://api.nuget.org/v3/index.json `
--skip-duplicate
}