|
1 | | -name: Publish to PowerShell Gallery |
| 1 | +name: Publish to PowerShell Gallery |
| 2 | + |
| 3 | +# Build and release the PsLogicAppExtractor PowerShell module on every push to main. |
| 4 | +# Validation jobs run in parallel with module caching; build-and-release runs after all pass. |
| 5 | + |
2 | 6 | on: |
3 | 7 | push: |
4 | 8 | branches: |
5 | 9 | - main |
6 | 10 |
|
7 | 11 | jobs: |
8 | | - build: |
9 | | - name: Push to Gallery |
| 12 | + general-unit-tests: |
| 13 | + name: Validate General Unit Tests |
10 | 14 | runs-on: windows-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 1 |
| 19 | + |
| 20 | + - name: Cache Powershell Modules |
| 21 | + id: cache-powershell-modules |
| 22 | + uses: actions/cache@v5 |
| 23 | + with: |
| 24 | + path: ~\Documents\PowerShell\Modules |
| 25 | + key: ps-modules-${{ runner.os }}-v1 |
| 26 | + |
| 27 | + - name: Install Prerequisites |
| 28 | + if: steps.cache-powershell-modules.outputs.cache-hit != 'true' |
| 29 | + shell: pwsh |
| 30 | + run: | |
| 31 | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted |
| 32 | + $modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake') |
| 33 | + foreach ($module in $modules) { |
| 34 | + Write-Host "Installing $module..." |
| 35 | + Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck |
| 36 | + } |
| 37 | +
|
| 38 | + - name: Validate |
| 39 | + shell: pwsh |
| 40 | + run: build\vsts-validate.ps1 -TestGeneral $true -TestFunctions $false |
11 | 41 |
|
| 42 | + individual-unit-tests: |
| 43 | + name: Validate Individual Unit Tests |
| 44 | + runs-on: windows-latest |
12 | 45 | steps: |
13 | | - - uses: actions/checkout@v3 |
14 | | - - name: Setup PowerShell module cache |
15 | | - id: cacher |
16 | | - uses: actions/cache@v3 |
| 46 | + - uses: actions/checkout@v4 |
17 | 47 | with: |
18 | | - path: "C:\\Users\\runneradmin\\Documents\\PowerShell\\Modules" |
19 | | - key: ${{ runner.os }}-PSFramework-PSScriptAnalyzer |
| 48 | + fetch-depth: 1 |
| 49 | + |
| 50 | + - name: Cache Powershell Modules |
| 51 | + id: cache-powershell-modules |
| 52 | + uses: actions/cache@v5 |
| 53 | + with: |
| 54 | + path: ~\Documents\PowerShell\Modules |
| 55 | + key: ps-modules-${{ runner.os }}-v1 |
| 56 | + |
20 | 57 | - name: Install Prerequisites |
21 | | - if: steps.cacher.outputs.cache-hit != 'true' |
22 | | - run: .\build\vsts-prerequisites.ps1 |
| 58 | + if: steps.cache-powershell-modules.outputs.cache-hit != 'true' |
23 | 59 | shell: pwsh |
24 | | - # - name: Validate |
25 | | - # run: .\build\vsts-validate.ps1 |
26 | | - # shell: pwsh |
| 60 | + run: | |
| 61 | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted |
| 62 | + $modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake') |
| 63 | + foreach ($module in $modules) { |
| 64 | + Write-Host "Installing $module..." |
| 65 | + Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck |
| 66 | + } |
| 67 | +
|
| 68 | + - name: Validate |
| 69 | + shell: pwsh |
| 70 | + run: build\vsts-validate.ps1 -TestGeneral $false -TestFunctions $true |
| 71 | + |
| 72 | + build-and-release: |
| 73 | + name: Build and Release |
| 74 | + runs-on: windows-latest |
| 75 | + needs: [general-unit-tests, individual-unit-tests] |
| 76 | + permissions: |
| 77 | + contents: write |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + with: |
| 81 | + fetch-depth: 1 |
| 82 | + |
| 83 | + - name: Cache Powershell Modules |
| 84 | + id: cache-powershell-modules |
| 85 | + uses: actions/cache@v5 |
| 86 | + with: |
| 87 | + path: ~\Documents\PowerShell\Modules |
| 88 | + key: ps-modules-${{ runner.os }}-v1 |
| 89 | + |
| 90 | + - name: Install Prerequisites |
| 91 | + if: steps.cache-powershell-modules.outputs.cache-hit != 'true' |
| 92 | + shell: pwsh |
| 93 | + run: | |
| 94 | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted |
| 95 | + $modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake') |
| 96 | + foreach ($module in $modules) { |
| 97 | + Write-Host "Installing $module..." |
| 98 | + Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck |
| 99 | + } |
| 100 | +
|
27 | 101 | - name: Build |
28 | | - run: .\build\vsts-build.ps1 -ApiKey $env:APIKEY -AutoVersion |
29 | 102 | shell: pwsh |
30 | | - env: |
31 | | - APIKEY: ${{ secrets.ApiKey }} |
| 103 | + run: .\build\vsts-build.ps1 -ApiKey ${{ secrets.ApiKey }} -AutoVersion:$true -SkipPublish:$false |
| 104 | + |
| 105 | + - name: Get version |
| 106 | + shell: pwsh |
| 107 | + run: | |
| 108 | + $publishDir = Get-Item -Path publish |
| 109 | + [version]$version = (Import-PowerShellDataFile -Path "$($publishDir.FullName)\PsLogicAppExtractor\PsLogicAppExtractor.psd1").ModuleVersion |
| 110 | + $githubReleaseVersion = "$($version.Major).$($version.Minor).$($version.Build)" |
| 111 | + "VERSION=$githubReleaseVersion" >> $env:GITHUB_ENV |
| 112 | +
|
| 113 | + - name: Create GitHub release |
| 114 | + uses: softprops/action-gh-release@v3 |
| 115 | + with: |
| 116 | + name: ${{ env.VERSION }} |
| 117 | + tag_name: ${{ env.VERSION }} |
| 118 | + draft: false |
| 119 | + prerelease: true |
| 120 | + generate_release_notes: true |
0 commit comments