-
-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (130 loc) · 4.58 KB
/
build.yml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: 🏗️🧪📦 WinTuner
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
workflow_dispatch:
jobs:
testps:
name: 🛠️ Test PowerShell Module
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: 👨💻 Check-out code
uses: actions/checkout@v4
- name: 👨🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: 🦸♂️ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: 🎒 Load packages
run: dotnet restore
- name: 🛠️ Build module
shell: pwsh
run:
dotnet build ./src/TokenMagician/TokenMagician.csproj --configuration Release --no-restore -p:Version="0.0.1-dev" -o ./dist/TokenMagician
- name: 📦 Install Pester
shell: pwsh
run: Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
- name: 🕵️ Import module and list commands
shell: pwsh
run: |
Import-Module ./dist/TokenMagician/TokenMagician.psd1
Get-Command -Module TokenMagician
- name: 🧪 Run test
shell: pwsh
run: |
Import-Module Pester
Import-Module ./dist/TokenMagician/TokenMagician.psd1
$pesterConfig = [PesterConfiguration]@{
Output = @{
Verbosity = "Normal"
CIFormat = "Auto"
StackTraceVerbosity = "FirstLine"
}
TestResult = @{
Enabled = $true
OutputPath = "${{ github.workspace }}/testresults/TestResults.xml"
OutputFormat = "JUnitXml"
}
Run = @{
Path = "./tests/TokenMagician"
Exit = $true
}
Should = @{
ErrorAction = "Continue"
}
}
Invoke-Pester -Configuration $pesterConfig
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: ${{ github.workspace }}/testresults/*.xml
publish-psgallery:
name: 📦 Publish TokenMagician to PowerShell Gallery
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [testps]
steps:
- name: 👨💻 Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 👨🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: 🦸♂️ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: 🎒 Load packages
run: dotnet restore
- name: 📝 Set module version
shell: pwsh
id: version
run: |
$version = "${{ github.ref_name }}".Substring(1)
$module = Get-Content -Path src/TokenMagician/TokenMagician.psd1
$module = $module -replace 'ModuleVersion = ''\d+\.\d+\.\d+''', "ModuleVersion = '$version'"
$module | Set-Content -Path src/TokenMagician/TokenMagician.psd1
- name: 🛠️ Build module
shell: pwsh
run: dotnet build ./src/TokenMagician/TokenMagician.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1)) -o ./dist/TokenMagician
- name: 🧪 Import module
shell: pwsh
run: |
Import-Module ./dist/TokenMagician/TokenMagician.psd1
Get-Command -Module TokenMagician
- name: 📦 Publish TokenMagician to PowerShell Gallery
shell: pwsh
run: |
Import-Module ./dist/TokenMagician/TokenMagician.psd1
Publish-Module -Path ./dist/TokenMagician -NuGetApiKey $env:PSGALLERY_TOKEN -Repository PSGallery -Force
env:
PSGALLERY_TOKEN: ${{ secrets.PSGALLERY_TOKEN }}