├── .github └── workflows │ └── pack.yaml ├── .gitignore ├── LICENSE ├── README.md └── src ├── icon.png ├── templatepack.csproj └── templates ├── .github └── workflows │ └── ci_build.yaml └── .template.config ├── dotnetcli.host.json └── template.json /.github/workflows/pack.yaml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - '**/*.md' 9 | - '**/*.gitignore' 10 | - '**/*.gitattributes' 11 | workflow_dispatch: 12 | branches: 13 | - main 14 | paths-ignore: 15 | - '**/*.md' 16 | - '**/*.gitignore' 17 | - '**/*.gitattributes' 18 | 19 | env: 20 | PACKAGE_PATH: './package' 21 | 22 | jobs: 23 | dotnet_workflow: 24 | name: Pack 25 | runs-on: windows-latest 26 | env: 27 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 28 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 29 | DOTNET_NOLOGO: true 30 | DOTNET_GENERATE_ASPNET_CERTIFICATE: false 31 | DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false 32 | DOTNET_MULTILEVEL_LOOKUP: 0 33 | DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true 34 | TERM: xterm 35 | 36 | steps: 37 | - uses: actions/checkout@v4 38 | 39 | - name: Setup .NET Core SDK 40 | uses: actions/setup-dotnet@v4 41 | with: 42 | dotnet-version: 8.0.x 43 | 44 | - name: Pack 45 | working-directory: src 46 | run: dotnet pack -o ${{ env.PACKAGE_PATH }} 47 | 48 | - name: Get certificate 49 | id: cert_file 50 | uses: timheuer/base64-to-file@v1 51 | with: 52 | fileName: 'certfile.pfx' 53 | encodedString: ${{ secrets.SIGNING_CERT }} 54 | 55 | # Sign the package 56 | - name: Sign NuGet Package 57 | run: dotnet nuget sign "**/*.nupkg" --certificate-path ${{ steps.cert_file.outputs.filePath }} --certificate-password "${{ secrets.CERT_PWD }}" --timestamper http://timestamp.digicert.com 58 | 59 | - name: Publish NuGet package 60 | run: dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json 61 | 62 | - name: Publish artifact 63 | uses: actions/upload-artifact@v4 64 | with: 65 | name: packaged-template 66 | path: ./src/package -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | 33 | # Visual Studio 2015/2017 cache/options directory 34 | .vs/ 35 | # Uncomment if you have tasks that create the project's static files in wwwroot 36 | #wwwroot/ 37 | 38 | # Visual Studio 2017 auto generated files 39 | Generated\ Files/ 40 | 41 | # MSTest test Results 42 | [Tt]est[Rr]esult*/ 43 | [Bb]uild[Ll]og.* 44 | 45 | # NUNIT 46 | *.VisualState.xml 47 | TestResult.xml 48 | 49 | # Build Results of an ATL Project 50 | [Dd]ebugPS/ 51 | [Rr]eleasePS/ 52 | dlldata.c 53 | 54 | # Benchmark Results 55 | BenchmarkDotNet.Artifacts/ 56 | 57 | # .NET Core 58 | project.lock.json 59 | project.fragment.lock.json 60 | artifacts/ 61 | 62 | # StyleCop 63 | StyleCopReport.xml 64 | 65 | # Files built by Visual Studio 66 | *_i.c 67 | *_p.c 68 | *_h.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.iobj 73 | *.pch 74 | *.pdb 75 | *.ipdb 76 | *.pgc 77 | *.pgd 78 | *.rsp 79 | *.sbr 80 | *.tlb 81 | *.tli 82 | *.tlh 83 | *.tmp 84 | *.tmp_proj 85 | *_wpftmp.csproj 86 | *.log 87 | *.vspscc 88 | *.vssscc 89 | .builds 90 | *.pidb 91 | *.svclog 92 | *.scc 93 | 94 | # Chutzpah Test files 95 | _Chutzpah* 96 | 97 | # Visual C++ cache files 98 | ipch/ 99 | *.aps 100 | *.ncb 101 | *.opendb 102 | *.opensdf 103 | *.sdf 104 | *.cachefile 105 | *.VC.db 106 | *.VC.VC.opendb 107 | 108 | # Visual Studio profiler 109 | *.psess 110 | *.vsp 111 | *.vspx 112 | *.sap 113 | 114 | # Visual Studio Trace Files 115 | *.e2e 116 | 117 | # TFS 2012 Local Workspace 118 | $tf/ 119 | 120 | # Guidance Automation Toolkit 121 | *.gpState 122 | 123 | # ReSharper is a .NET coding add-in 124 | _ReSharper*/ 125 | *.[Rr]e[Ss]harper 126 | *.DotSettings.user 127 | 128 | # JustCode is a .NET coding add-in 129 | .JustCode 130 | 131 | # TeamCity is a build add-in 132 | _TeamCity* 133 | 134 | # DotCover is a Code Coverage Tool 135 | *.dotCover 136 | 137 | # AxoCover is a Code Coverage Tool 138 | .axoCover/* 139 | !.axoCover/settings.json 140 | 141 | # Visual Studio code coverage results 142 | *.coverage 143 | *.coveragexml 144 | 145 | # NCrunch 146 | _NCrunch_* 147 | .*crunch*.local.xml 148 | nCrunchTemp_* 149 | 150 | # MightyMoose 151 | *.mm.* 152 | AutoTest.Net/ 153 | 154 | # Web workbench (sass) 155 | .sass-cache/ 156 | 157 | # Installshield output folder 158 | [Ee]xpress/ 159 | 160 | # DocProject is a documentation generator add-in 161 | DocProject/buildhelp/ 162 | DocProject/Help/*.HxT 163 | DocProject/Help/*.HxC 164 | DocProject/Help/*.hhc 165 | DocProject/Help/*.hhk 166 | DocProject/Help/*.hhp 167 | DocProject/Help/Html2 168 | DocProject/Help/html 169 | 170 | # Click-Once directory 171 | publish/ 172 | 173 | # Publish Web Output 174 | *.[Pp]ublish.xml 175 | *.azurePubxml 176 | # Note: Comment the next line if you want to checkin your web deploy settings, 177 | # but database connection strings (with potential passwords) will be unencrypted 178 | *.pubxml 179 | *.publishproj 180 | 181 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 182 | # checkin your Azure Web App publish settings, but sensitive information contained 183 | # in these scripts will be unencrypted 184 | PublishScripts/ 185 | 186 | # NuGet Packages 187 | *.nupkg 188 | # The packages folder can be ignored because of Package Restore 189 | **/[Pp]ackages/* 190 | # except build/, which is used as an MSBuild target. 191 | !**/[Pp]ackages/build/ 192 | # Uncomment if necessary however generally it will be regenerated when needed 193 | #!**/[Pp]ackages/repositories.config 194 | # NuGet v3's project.json files produces more ignorable files 195 | *.nuget.props 196 | *.nuget.targets 197 | 198 | # Microsoft Azure Build Output 199 | csx/ 200 | *.build.csdef 201 | 202 | # Microsoft Azure Emulator 203 | ecf/ 204 | rcf/ 205 | 206 | # Windows Store app package directories and files 207 | AppPackages/ 208 | BundleArtifacts/ 209 | Package.StoreAssociation.xml 210 | _pkginfo.txt 211 | *.appx 212 | *.appxbundle 213 | *.appxupload 214 | 215 | # Visual Studio cache files 216 | # files ending in .cache can be ignored 217 | *.[Cc]ache 218 | # but keep track of directories ending in .cache 219 | !?*.[Cc]ache/ 220 | 221 | # Others 222 | ClientBin/ 223 | ~$* 224 | *~ 225 | *.dbmdl 226 | *.dbproj.schemaview 227 | *.jfm 228 | *.pfx 229 | *.publishsettings 230 | orleans.codegen.cs 231 | 232 | # Including strong name files can present a security risk 233 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 234 | #*.snk 235 | 236 | # Since there are multiple workflows, uncomment next line to ignore bower_components 237 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 238 | #bower_components/ 239 | 240 | # RIA/Silverlight projects 241 | Generated_Code/ 242 | 243 | # Backup & report files from converting an old project file 244 | # to a newer Visual Studio version. Backup files are not needed, 245 | # because we have git ;-) 246 | _UpgradeReport_Files/ 247 | Backup*/ 248 | UpgradeLog*.XML 249 | UpgradeLog*.htm 250 | ServiceFabricBackup/ 251 | *.rptproj.bak 252 | 253 | # SQL Server files 254 | *.mdf 255 | *.ldf 256 | *.ndf 257 | 258 | # Business Intelligence projects 259 | *.rdl.data 260 | *.bim.layout 261 | *.bim_*.settings 262 | *.rptproj.rsuser 263 | *- Backup*.rdl 264 | 265 | # Microsoft Fakes 266 | FakesAssemblies/ 267 | 268 | # GhostDoc plugin setting file 269 | *.GhostDoc.xml 270 | 271 | # Node.js Tools for Visual Studio 272 | .ntvs_analysis.dat 273 | node_modules/ 274 | 275 | # Visual Studio 6 build log 276 | *.plg 277 | 278 | # Visual Studio 6 workspace options file 279 | *.opt 280 | 281 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 282 | *.vbw 283 | 284 | # Visual Studio LightSwitch build output 285 | **/*.HTMLClient/GeneratedArtifacts 286 | **/*.DesktopClient/GeneratedArtifacts 287 | **/*.DesktopClient/ModelManifest.xml 288 | **/*.Server/GeneratedArtifacts 289 | **/*.Server/ModelManifest.xml 290 | _Pvt_Extensions 291 | 292 | # Paket dependency manager 293 | .paket/paket.exe 294 | paket-files/ 295 | 296 | # FAKE - F# Make 297 | .fake/ 298 | 299 | # CodeRush personal settings 300 | .cr/personal 301 | 302 | # Python Tools for Visual Studio (PTVS) 303 | __pycache__/ 304 | *.pyc 305 | 306 | # Cake - Uncomment if you are using it 307 | # tools/** 308 | # !tools/packages.config 309 | 310 | # Tabs Studio 311 | *.tss 312 | 313 | # Telerik's JustMock configuration file 314 | *.jmconfig 315 | 316 | # BizTalk build output 317 | *.btp.cs 318 | *.btm.cs 319 | *.odx.cs 320 | *.xsd.cs 321 | 322 | # OpenCover UI analysis results 323 | OpenCover/ 324 | 325 | # Azure Stream Analytics local run output 326 | ASALocalRun/ 327 | 328 | # MSBuild Binary and Structured Log 329 | *.binlog 330 | 331 | # NVidia Nsight GPU debugger configuration file 332 | *.nvuser 333 | 334 | # MFractors (Xamarin productivity tool) working folder 335 | .mfractor/ 336 | 337 | # Local History for Visual Studio 338 | .localhistory/ 339 | 340 | # BeatPulse healthcheck temp database 341 | healthchecksdb 342 | 343 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 344 | MigrationBackup/ 345 | 346 | ## 347 | ## Visual studio for Mac 348 | ## 349 | 350 | 351 | # globs 352 | Makefile.in 353 | *.userprefs 354 | *.usertasks 355 | config.make 356 | config.status 357 | aclocal.m4 358 | install-sh 359 | autom4te.cache/ 360 | *.tar.gz 361 | tarballs/ 362 | test-results/ 363 | 364 | # Mac bundle stuff 365 | *.dmg 366 | *.app 367 | 368 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 369 | # General 370 | .DS_Store 371 | .AppleDouble 372 | .LSOverride 373 | 374 | # Icon must end with two \r 375 | Icon 376 | 377 | 378 | # Thumbnails 379 | ._* 380 | 381 | # Files that might appear in the root of a volume 382 | .DocumentRevisions-V100 383 | .fseventsd 384 | .Spotlight-V100 385 | .TemporaryItems 386 | .Trashes 387 | .VolumeIcon.icns 388 | .com.apple.timemachine.donotpresent 389 | 390 | # Directories potentially created on remote AFP share 391 | .AppleDB 392 | .AppleDesktop 393 | Network Trash Folder 394 | Temporary Items 395 | .apdisk 396 | 397 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 398 | # Windows thumbnail cache files 399 | Thumbs.db 400 | ehthumbs.db 401 | ehthumbs_vista.db 402 | 403 | # Dump file 404 | *.stackdump 405 | 406 | # Folder config file 407 | [Dd]esktop.ini 408 | 409 | # Recycle Bin used on file shares 410 | $RECYCLE.BIN/ 411 | 412 | # Windows Installer files 413 | *.cab 414 | *.msi 415 | *.msix 416 | *.msm 417 | *.msp 418 | 419 | # Windows shortcuts 420 | *.lnk 421 | 422 | # JetBrains Rider 423 | .idea/ 424 | *.sln.iml 425 | 426 | ## 427 | ## Visual Studio Code 428 | ## 429 | .vscode/* 430 | !.vscode/settings.json 431 | !.vscode/tasks.json 432 | !.vscode/launch.json 433 | !.vscode/extensions.json 434 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tim Heuer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Build](https://github.com/timheuer/dotnet-workflow/workflows/Build/badge.svg) 2 | 3 | # `dotnet new workflow` 4 | 5 | This is a simple global tool to give you a handy and quick method to create a GitHub Actions workflow file for continous integration (CI) builds. 6 | 7 | For more information on why you can read this blog post: [https://timheuer.com/blog/generate-github-actions-workflow-from-cli/](https://timheuer.com/blog/generate-github-actions-workflow-from-cli/). 8 | 9 | ## Usage 10 | 11 | To create a workflow for your project from the root of your source code (which would represent the root of your repo -- GitHub Actions workflows exist in the root of your repo). Some examples 12 | 13 | ### Default 14 | 15 | To use all the defaults: 16 | 17 | `dotnet new workflow` 18 | 19 | This generates the workflow with all the defaults: 20 | 21 | - latest SDK version using Major.Minor.x versioning (e.g., `8.0.x`) 22 | - workflow file will use project name 23 | - default branch of `main` 24 | 25 | ### Custom options 26 | 27 | To specify the name of your YAML file and/or the SDK version you want to use specify more options: 28 | 29 | `dotnet new workflow --sdk-version 8.0.100 -n build -b your_branch_name` 30 | -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timheuer/dotnet-workflow/56cb988125a1274775b8aff04d63ef7fdfda4215/src/icon.png -------------------------------------------------------------------------------- /src/templatepack.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Template 5 | TimHeuer.GitHubActions.Templates 6 | .NET Workflow Templates 7 | Tim Heuer 8 | Template for creating a GitHub Action workflow for CI for .NET 9 | dotnet-new;templates;github;actions;devops;workflow 10 | icon.png 11 | MIT 12 | netstandard2.0 13 | https://github.com/timheuer/dotnet-workflow 14 | https://github.com/timheuer/dotnet-workflow 15 | git 16 | true 17 | false 18 | content 19 | 1.2.0 20 | README.md 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | True 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/templates/.github/workflows/ci_build.yaml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | push: 5 | branches: 6 | - Workflow.Branch 7 | paths-ignore: 8 | - '**/*.md' 9 | - '**/*.gitignore' 10 | - '**/*.gitattributes' 11 | pull_request: 12 | branches: 13 | - Workflow.Branch 14 | paths-ignore: 15 | - '**/*.md' 16 | - '**/*.gitignore' 17 | - '**/*.gitattributes' 18 | workflow_dispatch: 19 | 20 | jobs: 21 | build: 22 | name: Build 23 | runs-on: ubuntu-latest 24 | env: 25 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 26 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 27 | DOTNET_NOLOGO: true 28 | DOTNET_GENERATE_ASPNET_CERTIFICATE: false 29 | DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false 30 | DOTNET_MULTILEVEL_LOOKUP: 0 31 | DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true 32 | TERM: xterm 33 | 34 | steps: 35 | - uses: actions/checkout@v4 36 | 37 | - name: Setup .NET SDK 38 | uses: actions/setup-dotnet@v4 39 | with: 40 | dotnet-version: Workflow.SDKVersion 41 | 42 | # if not using any workloads (e.g, Aspire, Wasm, Maui), remove this step 43 | - name: Restore workloads 44 | run: dotnet workload restore 45 | 46 | - name: Restore 47 | run: dotnet restore 48 | 49 | - name: Build 50 | run: dotnet build --configuration Release --no-restore 51 | 52 | - name: Test 53 | run: dotnet test 54 | -------------------------------------------------------------------------------- /src/templates/.template.config/dotnetcli.host.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/dotnetcli.host", 3 | "symbolInfo": { 4 | "sdk-version": { 5 | "longName": "sdk-version", 6 | "shortName": "sdk" 7 | }, 8 | "dotnet-cli-version": { 9 | "isHidden": "true" 10 | } 11 | }, 12 | "usageExamples": [ 13 | "--sdk-version 8.0.204", 14 | "-sdk 8.0.x", 15 | "-sdk 8.0.x -n build" 16 | ] 17 | } -------------------------------------------------------------------------------- /src/templates/.template.config/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "author": "Tim Heuer", 4 | "classifications": [ 5 | "Config", 6 | "Common", 7 | "Code", 8 | "Web" 9 | ], 10 | "identity": "TimHeuer.GitHubWorkflows", 11 | "name": "GitHub Actions workflow for .NET", 12 | "generatorVersions": "[1.0.0.0-*)", 13 | "description": "A workflow file for .NET apps to use in GitHub Actions", 14 | "shortName": "workflow", 15 | "sourceName": "ci_build", 16 | "primaryOutputs": [ 17 | { 18 | "path": ".github/workflows/build.yaml" 19 | } 20 | ], 21 | "tags": { 22 | "language": "YAML", 23 | "type": "item" 24 | }, 25 | "defaultName": "build", 26 | "symbols": { 27 | "HostIdentifier": { 28 | "type": "bind", 29 | "binding": "HostIdentifier" 30 | }, 31 | "sdk-version": { 32 | "description": "The SDK version for the generated workflow", 33 | "type": "parameter", 34 | "datatype": "string", 35 | "displayName": "SDK version" 36 | }, 37 | "branch": { 38 | "description": "The branch for the workflow to operate on", 39 | "replaces": "Workflow.Branch", 40 | "type": "parameter", 41 | "defaultValue": "main", 42 | "datatype": "string", 43 | "displayName": "Branch" 44 | }, 45 | "dotnet-cli-version": { 46 | "type": "parameter", 47 | "datatype": "string", 48 | "displayName": "dotnet CLI version" 49 | }, 50 | "CombinedVersion": { 51 | "type": "generated", 52 | "generator": "coalesce", 53 | "parameters": { 54 | "sourceVariableName": "sdk-version", 55 | "fallbackVariableName": "dotnet-cli-version" 56 | }, 57 | "replaces": "Workflow.SDKVersion" 58 | } 59 | }, 60 | "postActions": [ 61 | { 62 | "id": "open-file", 63 | "description": "Open the workflow file in the editor", 64 | "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", 65 | "args": { 66 | "files": "0" 67 | }, 68 | "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", 69 | "continueOnError": true 70 | } 71 | ] 72 | } --------------------------------------------------------------------------------