Skip to content

馃懛 Updates Build Scripts #9

馃懛 Updates Build Scripts

馃懛 Updates Build Scripts #9

Workflow file for this run

name: Validate Changes
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint-with-psscriptanalyzer:
name: Lint with PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: "Cache: Nested PSGallery Modules"
id: cacher
uses: actions/cache@v3
with:
path: ./lib
key: lib-PSGallery-${{ hashFiles('./NuGet.PSGallery.config', './packages.PSGallery.config') }}
- name: Install NuGet
uses: nuget/[email protected]
if: steps.cacher.outputs.cache-hit != 'true'
with:
nuget-version: '6.x'
- name: Restore Nested PSGallery Modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
./build/restore.ps1
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: ./build/lint.ps1 -NoFail
determine-version:
name: Determine Version with GitVersion
runs-on: ubuntu-latest
steps:
- name: Cache dotnet tools
id: cacher
uses: actions/cache@v3
with:
path: |
${{ env.HOME }}/.dotnet/tools
${{ env.USERPROFILE }}\\.dotnet\\tools
key: ${{ runner.os }}-dotnet-tools-${{ hashFiles('**/global.json') }}
- name: dotnet tool install -g GitVersion.Tool
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: dotnet tool install --global GitVersion.Tool --version 5.12
- name: Check out repository full history
uses: actions/checkout@v3
with:
fetch-depth: 0 # GitVersion requires the full history to calculate the version.
- name: Show GitVersion configuration
shell: pwsh
run: dotnet-gitversion /showconfig
- name: Capture GitVersion configuration
shell: pwsh
run: |
New-Item -Path ./out -Type Directory -Force | Out-Null
dotnet-gitversion /showconfig | Out-File -Path ./out/GitVersion.effective.yml -Encoding UTF8
- name: Determine version
shell: pwsh
run: |
dotnet-gitversion /output json | Out-File -Path ./out/version.json -Encoding UTF8
[int] $gitversionExitCode = $LASTEXITCODE
if ($gitversionExitCode -ne 0) {
Write-Host "GitVersion failed. Re-running with diagnostic verbosity."
dotnet-gitversion /output json /verbosity diagnostic
exit $gitversionExitCode
}
- name: Upload version.json
uses: actions/upload-artifact@v3
with:
name: version.json
path: ./out/version.json
create-releasenotes:
name: Create Release Notes
needs: determine-version
runs-on: ubuntu-latest
steps:
- name: Check out repository full history
uses: actions/checkout@v3
with:
fetch-depth: 0 # create-release-notes requires the full history to create the release notes.
- name: Download version.json
uses: actions/download-artifact@v2
with:
name: version.json
path: ./out/
- name: Populate version variables
id: gitversion_vars
shell: pwsh
run: |
[object] $version = Get-Content -Path ./out/version.json | ConvertFrom-Json
foreach ($key in $version.PSObject.Properties.Name) {
echo "::set-output name=$key::$($version.$key)"
}
- name: Create release notes
id: create_release_notes
uses: mikepenz/release-changelog-builder-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fromTag: ${{ steps.gitversion_vars.outputs.VersionSourceSha }}
toTag: ${{ steps.gitversion_vars.outputs.Sha }}
commitMode: true
outputFile: ./out/release-notes.md
- name: Upload release-notes.md
uses: actions/upload-artifact@v2
with:
name: release-notes.md
path: ./out/release-notes.md
build-release-package:
name: Build Release Package
needs: [create-releasenotes]
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: "Cache: Nested PSGallery Modules"
id: cacher
uses: actions/cache@v3
with:
path: ./lib
key: lib-PSGallery-${{ hashFiles('./NuGet.PSGallery.config', './packages.PSGallery.config') }}
- name: Install NuGet
uses: nuget/[email protected]
if: steps.cacher.outputs.cache-hit != 'true'
with:
nuget-version: '6.x'
- name: Restore Nested PSGallery Modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
./build/restore.ps1
- name: Download version.json
uses: actions/download-artifact@v2
with:
name: version.json
path: ./out/
- name: Populate GitVersion variables
id: gitversion_vars
shell: pwsh
run: |
[object] $version = Get-Content -Raw -Path ./out/version.json -Encoding UTF8 | ConvertFrom-Json
foreach ($key in $version.PSObject.Properties.Name) {
echo "::set-output name=$key::$($version.$key)"
}
- name: Download release notes
uses: actions/download-artifact@v2
with:
name: release-notes.md
path: ./out/
- name: Build PSGallery package
shell: pwsh
run: |
[string] $releaseNotes = (Get-Content -Raw -Path ./out/release-notes.md -Encoding UTF8).Trim()
[object] $version = Get-Content -Raw -Path ./out/version.json -Encoding UTF8 | ConvertFrom-Json
./build/package.ps1 -PackageVersionNuGet $version.NuGetVersionV2 -PackageVersionMajorMinorPatchBuild $version.AssemblySemVer -PackageVersionPrereleaseTag $version.PrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $version.Sha
- name: Upload PSGallery package
uses: actions/upload-artifact@v3
with:
name: PSGallery-package
path: ./out/*.nupkg
test-ubuntu-latest:
name: Test with Pester on Ubuntu Latest
needs: build-release-package
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: "Cache: Nested PSGallery Modules"
id: cacher
uses: actions/cache@v3
with:
path: ./lib
key: lib-PSGallery-${{ hashFiles('./NuGet.PSGallery.config', './packages.PSGallery.config') }}
- name: Install NuGet
uses: nuget/[email protected]
if: steps.cacher.outputs.cache-hit != 'true'
with:
nuget-version: '6.x'
- name: Restore Nested PSGallery Modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
./build/restore.ps1
- name: Download PSGallery package
uses: actions/download-artifact@v2
with:
name: PSGallery-package
path: ./out/
- name: Test with Pester
shell: pwsh
run: ./build/test.ps1 -UsePackageExport
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: tests-ubuntu-latest
path: ./out/test-*.xml
if: ${{ always() }}
test-windows-latest:
name: Test with Pester on Windows Latest
needs: build-release-package
runs-on: windows-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: "Cache: Nested PSGallery Modules"
id: cacher
uses: actions/cache@v3
with:
path: ./lib
key: lib-PSGallery-${{ hashFiles('./NuGet.PSGallery.config', './packages.PSGallery.config') }}
- name: Install NuGet
uses: nuget/[email protected]
if: steps.cacher.outputs.cache-hit != 'true'
with:
nuget-version: '6.x'
- name: Restore Nested PSGallery Modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
./build/restore.ps1
- name: Download PSGallery package
uses: actions/download-artifact@v2
with:
name: PSGallery-package
path: ./out/
- name: Test with Pester
shell: pwsh
run: ./build/test.ps1 -UsePackageExport
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: tests-windows-latest
path: ./out/test-*.xml
if: ${{ always() }}
test-macos-latest:
name: Test with Pester on MacOS Latest
needs: build-release-package
runs-on: macos-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: "Cache: Nested PSGallery Modules"
id: cacher
uses: actions/cache@v3
with:
path: ./lib
key: lib-PSGallery-${{ hashFiles('./NuGet.PSGallery.config', './packages.PSGallery.config') }}
- name: Install NuGet
uses: nuget/[email protected]
if: steps.cacher.outputs.cache-hit != 'true'
with:
nuget-version: '6.x'
- name: Restore Nested PSGallery Modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
./build/restore.ps1
- name: Download PSGallery package
uses: actions/download-artifact@v2
with:
name: PSGallery-package
path: ./out/
- name: Test with Pester
shell: pwsh
run: ./build/test.ps1 -UsePackageExport -NoFail
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: tests-macos-latest
path: out/test-*.xml
if: ${{ always() }}