1+ name : Build and Publish Template Package
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Package version (e.g., 1.0.0)'
8+ required : true
9+ default : ' 1.0.0'
10+ author :
11+ description : ' Template author'
12+ required : true
13+ default : ' Nitin Singh'
14+ description :
15+ description : ' Template description'
16+ required : true
17+ default : ' Full-stack Clean Architecture template with .NET 9 API and Angular 19'
18+
19+ jobs :
20+ build-and-publish :
21+ runs-on : windows-latest
22+
23+ env :
24+ TEMPLATE_VERSION : ${{ github.event.inputs.version }}
25+ TEMPLATE_AUTHOR : ${{ github.event.inputs.author }}
26+ TEMPLATE_DESCRIPTION : ${{ github.event.inputs.description }}
27+ NUGET_AUTH_TOKEN : ${{ secrets.NUGET_API_KEY }}
28+
29+ steps :
30+ - name : Checkout repository
31+ uses : actions/checkout@v3
32+ with :
33+ fetch-depth : 0
34+
35+ - name : Setup .NET
36+ uses : actions/setup-dotnet@v3
37+ with :
38+ dotnet-version : ' 9.0.x'
39+
40+ - name : Setup NuGet
41+ uses : NuGet/setup-nuget@v1
42+ with :
43+ nuget-version : ' 6.x'
44+
45+ - name : Display version
46+ run : echo "Building template version ${{ env.TEMPLATE_VERSION }}"
47+
48+ - name : Create output directories
49+ run : |
50+ mkdir template-output
51+ mkdir nupkg
52+
53+ - name : Run template preparation script
54+ shell : pwsh
55+ run : |
56+ ./CreateTemplate.ps1 -SourceDirectory . -TemplateNamespace Contact -OutputDirectory ./template-output
57+
58+ - name : Create .nuspec file
59+ shell : pwsh
60+ run : |
61+ $nuspecContent = @"
62+ <?xml version="1.0" encoding="utf-8"?>
63+ <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
64+ <metadata>
65+ <id>CleanArchitecture.FullStack.Template</id>
66+ <version>${{ env.TEMPLATE_VERSION }}</version>
67+ <title>Clean Architecture Full-Stack Template</title>
68+ <authors>${{ env.TEMPLATE_AUTHOR }}</authors>
69+ <description>${{ env.TEMPLATE_DESCRIPTION }}</description>
70+ <tags>dotnet-new template cleanarchitecture angular fullstack docker postgresql</tags>
71+ <packageTypes>
72+ <packageType name="Template" />
73+ </packageTypes>
74+ <repository type="git" url="https://github.com/nitin27may/clean-architecture-docker-dotnet-angular" />
75+ <license type="expression">MIT</license>
76+ <projectUrl>https://github.com/nitin27may/clean-architecture-docker-dotnet-angular</projectUrl>
77+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
78+ <copyright>Copyright © ${{ env.TEMPLATE_AUTHOR }} $((Get-Date).Year)</copyright>
79+ <summary>A full-stack template using Clean Architecture principles with .NET 9 API backend and Angular 19 frontend, containerized with Docker.</summary>
80+ </metadata>
81+ </package>
82+ "@
83+
84+ Set-Content -Path "./template-output/CleanArchitecture.FullStack.Template.nuspec" -Value $nuspecContent
85+
86+ - name : Update template.json metadata
87+ shell : pwsh
88+ run : |
89+ $templateJsonPath = "./template-output/.template.config/template.json"
90+ $templateJson = Get-Content -Path $templateJsonPath -Raw | ConvertFrom-Json
91+
92+ $templateJson.author = "${{ env.TEMPLATE_AUTHOR }}"
93+ $templateJson | ConvertTo-Json -Depth 10 | Set-Content -Path $templateJsonPath
94+
95+ - name : Pack template
96+ run : |
97+ nuget pack ./template-output/CleanArchitecture.FullStack.Template.nuspec -OutputDirectory ./nupkg
98+
99+ - name : Test template package
100+ run : |
101+ dotnet new install ./nupkg/CleanArchitecture.FullStack.Template.${{ env.TEMPLATE_VERSION }}.nupkg
102+ mkdir test-project
103+ cd test-project
104+ dotnet new cleanarch-fullstack --Organization TestCompany
105+
106+ - name : Upload package artifact
107+ uses : actions/upload-artifact@v4
108+ with :
109+ name : nuget-package
110+ path : ./nupkg/*.nupkg
111+
112+ - name : Push to NuGet
113+ run : |
114+ dotnet nuget push ./nupkg/CleanArchitecture.FullStack.Template.${{ env.TEMPLATE_VERSION }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
0 commit comments