Skip to content

ci: Switch some build command to pwsh #10

ci: Switch some build command to pwsh

ci: Switch some build command to pwsh #10

Workflow file for this run

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