Skip to content

Commit e62a91b

Browse files
feat: create dotnet template powershell (#1)
1 parent 980e6b0 commit e62a91b

30 files changed

+12018
-2
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
# Matches multiple files with brace expansion notation
10+
# Set default charset
11+
[*.{config,nuspec,ps1,yml}]
12+
charset = utf-8
13+
14+
[*.ps1]
15+
indent_style = space
16+
indent_size = 4
17+
18+
[*.{config,nuspec,yml}]
19+
indent_style = space
20+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.* eol=lf
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: compendium.powershell pipeline
2+
on:
3+
push:
4+
pull_request:
5+
branches:
6+
- main
7+
concurrency:
8+
group: ${{ github.ref }}
9+
cancel-in-progress: true
10+
env:
11+
PACKAGE_NAME: Compendium.PowerShell.nupkg
12+
ARTIFACT_NAME: Compendium.PowerShell
13+
NODE_VERSION: '18'
14+
NUGET_VERSION: '6.3.0'
15+
defaults:
16+
run:
17+
shell: pwsh
18+
jobs:
19+
SemanticVersion:
20+
runs-on: ubuntu-22.04
21+
outputs:
22+
semantic_version: ${{ steps.semantic_release.outputs.SEMANTIC_VERSION }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
with:
27+
persist-credentials: false
28+
- name: Setup Node Version
29+
uses: actions/setup-node@master
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
- name: Node Package Restore
33+
run: ./build/scripts/Install-NodePackages.ps1
34+
- name: Semantic Release (Dry-Run)
35+
id: semantic_release
36+
run: ./build/scripts/Invoke-SemanticRelease.ps1 -DryRun
37+
env:
38+
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
39+
GH_REF: ${{ github.ref }}
40+
Test:
41+
runs-on: ubuntu-22.04
42+
defaults:
43+
run:
44+
shell: pwsh
45+
working-directory: src/Compendium.PowerShell/Compendium
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v3
49+
with:
50+
persist-credentials: false
51+
- name: Install PSDepend
52+
working-directory: ${{ github.workspace }}
53+
run: ./build/scripts/Install-PSDepend.ps1
54+
- name: Install Requirements
55+
working-directory: ${{ github.workspace }}
56+
run: ./build/scripts/Install-Requirements.ps1
57+
- name: Test PowerShell Module Manifest
58+
run: ./../../../build/scripts/Test-PowerShellModuleManifest.ps1
59+
- name: Pester Tests
60+
run: ./../../../build/scripts/Test-PowerShell.ps1
61+
- name: PSScriptAnalyzer
62+
run: ./../../../build/scripts/Test-PowerShellLinting.ps1
63+
Build:
64+
runs-on: ubuntu-22.04
65+
needs:
66+
- SemanticVersion
67+
- Test
68+
defaults:
69+
run:
70+
shell: pwsh
71+
working-directory: src
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v3
75+
- uses: nuget/setup-nuget@v2
76+
with:
77+
nuget-version: ${{ env.NUGET_VERSION }}
78+
- name: Package Template
79+
run: ./../build/scripts/Export-Package.ps1 -Nuspec "Compendium.PowerShell.nuspec" -SemanticVersion "${{ needs.SemanticVersion.outputs.semantic_version }}"
80+
- name: Publish Artifact
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{ env.ARTIFACT_NAME }}
84+
path: src/${{ env.PACKAGE_NAME }}
85+
Release:
86+
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
87+
runs-on: ubuntu-22.04
88+
needs:
89+
- SemanticVersion
90+
- Build
91+
defaults:
92+
run:
93+
shell: pwsh
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v3
97+
- name: Download Artifact
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: ${{ env.ARTIFACT_NAME }}
101+
path: a/${{ env.ARTIFACT_NAME }}
102+
- uses: nuget/setup-nuget@v2
103+
with:
104+
nuget-api-key: ${{ secrets.NUGETAPIKEY }}
105+
nuget-version: ${{ env.NUGET_VERSION }}
106+
- name: Setup Node Version
107+
uses: actions/setup-node@master
108+
with:
109+
node-version: ${{ env.NODE_VERSION }}
110+
- name: Node Package Restore
111+
run: ./build/scripts/Install-NodePackages.ps1
112+
- name: Semantic Release
113+
id: semantic_release
114+
run: ./build/scripts/Invoke-SemanticRelease.ps1
115+
env:
116+
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
117+
GH_REF: ${{ github.ref }}
118+
- name: Publish Package
119+
run: |
120+
./build/scripts/Publish-Package.ps1 -PackagePath "a/${{ env.ARTIFACT_NAME }}/${{ env.PACKAGE_NAME }}"
121+
env:
122+
NUGETSOURCE: ${{ vars.NUGETSOURCE }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.nupkg
2+
node_modules

.releaserc.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
branches:
2+
- main
3+
4+
plugins:
5+
- path: "@semantic-release/commit-analyzer"
6+
preset: conventionalcommits
7+
releaseRules:
8+
- type: docs
9+
release: patch
10+
- type: refactor
11+
release: patch
12+
- path: "@semantic-release/release-notes-generator"
13+
preset: conventionalcommits
14+
- path: "@semantic-release/changelog"
15+
- path: "@semantic-release/exec"
16+
verifyReleaseCmd: "echo '${nextRelease.version}' > SEMANTIC-VERSION.txt"
17+
generateNotesCmd: "echo '${nextRelease.notes}' > RELEASE-NOTES.md"
18+
- path: "@semantic-release/github"
19+
assets:
20+
- path: a/Compendium.PowerShell/Compendium.PowerShell.nupkg
21+
label: Compendium.PowerShell.nupkg
22+
- path: "@semantic-release/git"
23+
assets:
24+
- CHANGELOG.md
25+
- RELEASE-NOTES.md

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Richard
3+
Copyright (c) 2023 Richard Bolhofer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
# dotnet-template-compendium-powershell
1+
# Compendium.PowerShell Template
2+
23
Custom PowerShell template for dotnet new.
4+
5+
# Local Testing
6+
7+
```powershell
8+
nuget pack Compendium.PowerShell.nuspec -NoDefaultExcludes -Version 0.0.1
9+
dotnet new install Compendium.PowerShell.0.0.1.nupkg
10+
dotnet new uninstall Compendium.PowerShell
11+
```
12+
13+
## Documentation
14+
15+
* [https://github.com/dotnet/templating/wiki/](https://github.com/dotnet/templating/wiki/)
16+
* [https://github.com/dotnet/dotnet-template-samples/tree/master](https://github.com/dotnet/dotnet-template-samples/tree/master)

build/scripts/Export-Package.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
param (
2+
[String] $Nuspec,
3+
[string] $SemanticVersion
4+
)
5+
6+
nuget pack $Nuspec -NoDefaultExcludes -OutputFileNamesWithoutVersion -Version $SemanticVersion
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm install

build/scripts/Install-PSDepend.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Set-PSRepository PSGallery -InstallationPolicy Trusted
2+
Install-Module -Name 'PSDepend' -ErrorAction Stop
3+
Import-Module -Name 'PSDepend' -ErrorAction Stop

0 commit comments

Comments
 (0)