👷 Updates Publish Workflow #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -CI -NoFail:([bool]"${{ secrets.MANDATE_LINT_SUCCESS != 'true' }}") | |
determine-version: | |
name: Determine Version with GitVersion | |
runs-on: ubuntu-latest | |
steps: | |
- name: Populate GitVersion variables | |
id: gitversion_vars | |
uses: pwshrc/[email protected] | |
with: | |
mode: 'upload' | |
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: Populate GitVersion variables | |
id: gitversion_vars | |
uses: pwshrc/[email protected] | |
with: | |
mode: 'download' | |
- 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: ./release-notes.md | |
- name: "Create artifact: release-notes.md" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-notes.md | |
path: ./release-notes.md | |
if-no-files-found: error | |
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: Populate GitVersion variables | |
id: gitversion_vars | |
uses: pwshrc/[email protected] | |
with: | |
mode: 'download' | |
- name: "Get artifact: release-notes.md" | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-notes.md | |
path: ./out/ | |
- name: Build PSGallery package | |
shell: pwsh | |
env: | |
PackageVersionNuGet: ${{ steps.gitversion_vars.outputs.NuGetVersionV2 }} | |
PackageVersionMajorMinorPatchBuild: ${{ steps.gitversion_vars.outputs.AssemblySemVer }} | |
PackageVersionPrereleaseTag: ${{ steps.gitversion_vars.outputs.PreReleaseTag }} | |
CommitSha: ${{ steps.gitversion_vars.outputs.Sha }} | |
run: | | |
[string] $releaseNotes = (Get-Content -Raw -Path ./out/release-notes.md -Encoding UTF8).Trim() | |
./build/package.ps1 -PackageVersionNuGet $Env:PackageVersionNuGet -PackageVersionMajorMinorPatchBuild $Env:PackageVersionMajorMinorPatchBuild -PackageVersionPrereleaseTag $Env:PackageVersionPrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $Env:CommitSha | |
- name: "Create artifact: PSGallery-package" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: PSGallery-package | |
path: ./out/*.nupkg | |
if-no-files-found: error | |
tests: | |
name: Test with Pester on ${{ matrix.os }} | |
continue-on-error: ${{ matrix.experimental == 'true' }} | |
strategy: | |
fail-fast: ${{ github.ref == 'refs/heads/main' }} | |
matrix: | |
# See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners | |
os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-20.04, windows-2019] | |
include: | |
- os: windows-latest | |
codecov_os: windows | |
- os: ubuntu-latest | |
codecov_os: linux | |
- os: macos-latest | |
codecov_os: macos | |
experimental: true | |
- os: ubuntu-20.04 | |
codecov_os: linux | |
experimental: true | |
- os: windows-2019 | |
codecov_os: windows | |
experimental: true | |
runs-on: ${{ matrix.os }} | |
needs: build-release-package | |
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: "Get artifact: PSGallery-package" | |
uses: actions/download-artifact@v3 | |
with: | |
name: PSGallery-package | |
path: ./out/ | |
- name: Test with Pester | |
shell: pwsh | |
run: ./build/test.ps1 -UsePackageExport -CI -OutputFilesPrefix "${{ matrix.os }}-" -NoFail:([bool]"${{ matrix.experimental }}") | |
- name: "Create artifact: tests-${{ matrix.os }}" | |
uses: actions/upload-artifact@v3 | |
if: ${{ always() }} | |
with: | |
name: "tests-${{ matrix.os }}" | |
path: ./out/*.xml | |
if-no-files-found: error | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v3 | |
if: ${{ (github.ref == 'refs/heads/main') }} | |
with: | |
fail_ci_if_error: true | |
flags: ${{ matrix.codecov_os }},unittests | |
directory: ./out | |
files: "*coverage.xml" | |
os: ${{ matrix.codecov_os }} | |
env_vars: "OS" |