-
-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (76 loc) · 3.28 KB
/
build-module.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
name: Publish to PowerShell Gallery
on:
push:
branches:
- main
# - develop
paths:
- 'src/SvR.ContentPrep/**'
- 'src/SvR.ContentPrep.Cmdlet/**'
- '.github/workflows/build-module.yml'
tags:
- v*
workflow_dispatch:
jobs:
build-and-publish:
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: 👨💻 Check-out code
uses: actions/checkout@v4
# Specify depth because of GitVersion
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: 🛠️ Compute version with GitVersion
id: gitversion
shell: pwsh
run: |
dotnet tool install --global GitVersion.Tool --version 5.*
# echo "## 📦 Calculated version" >> $GITHUB_STEP_SUMMARY
# echo "" >> $GITHUB_STEP_SUMMARY
$gitversion = & "dotnet-gitversion.exe" "/updateprojectfiles" "/output" "buildserver" "/nofetch" "/showvariable" "AssemblySemVer"
$env:GITHUB_OUTPUT = "version=$gitversion";
- 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\SvR.ContentPrep.Cmdlet\SvRooij.ContentPrep.Cmdlet.psd1
$module = $module -replace 'ModuleVersion = ''\d+\.\d+\.\d+''', "ModuleVersion = '$version'"
$module | Set-Content -Path src\SvR.ContentPrep.Cmdlet\SvRooij.ContentPrep.Cmdlet.psd1
- name: 🛠️ Build PowerShell module
shell: pwsh
run: dotnet build .\src\SvR.ContentPrep.Cmdlet\SvR.ContentPrep.Cmdlet.csproj -c Release -p:Version=$("${{ github.ref_name }}".Substring(1)) -o .\dist\SvRooij.ContentPrep.Cmdlet
- name: 🕵️ Import and test module
shell: pwsh
run: |
Import-Module .\dist\SvRooij.ContentPrep.Cmdlet\SvRooij.ContentPrep.Cmdlet.psd1
Get-Command -Module SvRooij.ContentPrep.Cmdlet
Get-Command -Module SvRooij.ContentPrep.Cmdlet | Select-Object -ExpandProperty Name | ForEach-Object { Get-Help $_ -Full }
- name: ✈️ Publish to PowerShell Gallery
shell: pwsh
run: |
Import-Module .\dist\SvRooij.ContentPrep.Cmdlet\SvRooij.ContentPrep.Cmdlet.psd1
Publish-Module -Path .\dist\SvRooij.ContentPrep.Cmdlet\ -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }} -Verbose
# - name: Analyses
# shell: pwsh
# run: |
# Import-Module .\dist\SvRooij.ContentPrep.Cmdlet\SvR.ContentPrep.Cmdlet.psd1
# Install-Module -Name PSScriptAnalyzer
# Invoke-ScriptAnalyzer -Path .\dist\SvRooij.ContentPrep.Cmdlet\SvR.ContentPrep.Cmdlet.psd1