-
Notifications
You must be signed in to change notification settings - Fork 7
72 lines (67 loc) · 3.17 KB
/
build-test-publish.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
name: Publish to PSGallery
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
on:
push:
branches:
- main
- prerelease
permissions:
contents: write
jobs:
publish-to-psgallery:
name: Publish
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Version Bump
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& .\PwshSpectreConsole\Build.ps1
$env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":"
$version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version
if($null -eq $version) { throw "Failed to load version" }
$newVersion = [version]::new($version.Major, $version.Minor + 1, 0)
Write-Host "Bumping version from $version to $newVersion"
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion
git config --global user.name 'Shaun Lawrie (via GitHub Actions)'
git config --global user.email '[email protected]'
git add PwshSpectreConsole/PwshSpectreConsole.psd1
git commit -m "[skip ci] Bump version to $newVersion"
git push
- name: Deploy Package
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Publish-Module -Path "./PwshSpectreConsole/" -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY
publish-prerelease-to-psgallery:
name: Publish Prerelease
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/prerelease'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Version Bump and Publish
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& ./PwshSpectreConsole/Build.ps1
$env:PSModulePath = @($env:PSModulePath, ".\PwshSpectreConsole\") -join ":"
$version = Get-Module PwshSpectreConsole -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version
if($null -eq $version) { throw "Failed to load version" }
$newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1)
Write-Host "Bumping version from $version to $newVersion"
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -ModuleVersion $newVersion
git config --global user.name 'Shaun Lawrie (via GitHub Actions)'
git config --global user.email '[email protected]'
git add PwshSpectreConsole/PwshSpectreConsole.psd1
git commit -m "[skip ci] Bump version to $newVersion"
git push
# Mark as prerelease
Update-ModuleManifest -Path .\PwshSpectreConsole\PwshSpectreConsole.psd1 -PrivateData @{ Prerelease = 'prerelease' }
# Publish pre-release version
Import-Module .\PwshSpectreConsole\PwshSpectreConsole.psd1 -Force
Publish-Module -Name PwshSpectreConsole -Exclude "Build.ps1" -NugetApiKey $env:PSGALLERY_API_KEY -AllowPrerelease