@@ -30,77 +30,68 @@ jobs:
3030 - name : Cache PowerShell Modules
3131 uses : actions/cache@v3
3232 with :
33- path : |
34- $env:USERPROFILE\Documents\WindowsPowerShell\Modules
33+ path : C:\Users\runneradmin\Documents\PowerShell\Modules
3534 key : ${{ runner.os }}-powershell-modules
3635 restore-keys : ${{ runner.os }}-powershell-modules-
3736
3837 - name : Install Rust
3938 shell : pwsh
40- run : rustup update stable && rustup default stable
39+ run : |
40+ rustup update stable
41+ rustup default stable
4142
4243 - name : Install PSSemVer
4344 shell : pwsh
4445 run : |
45- try {
46- Import-Module -Name PSSemVer -ErrorAction Stop
47- } catch {
48- Write-Host "Installing PSSemVer module..."
46+ if (-not (Get-Module -ListAvailable -Name PSSemVer)) {
4947 Install-Module -Name PSSemVer -Scope CurrentUser -Force -ErrorAction Stop
50- Import-Module -Name PSSemVer -ErrorAction Stop
5148 }
49+ Import-Module -Name PSSemVer -ErrorAction Stop
5250
5351 - name : Extract Branch Version
5452 id : extract_version
5553 shell : pwsh
5654 run : |
5755 $branchName = "${{ github.ref_name }}"
56+ $rawVersion = $branchName -replace '^release/', ''
57+ Import-Module -Name PSSemVer -ErrorAction Stop
5858 try {
59- $rawVersion = $branchName -replace '^release/', ''
6059 $expectedVersion = [PSSemVer]::Parse($rawVersion)
61-
62- Write-Output "expected_version=$expectedVersion" | Out-File -FilePath $GITHUB_OUTPUT -Encoding utf8
63- Write-Host "Expected version for crates: $expectedVersion"
6460 } catch {
65- Write-Error "Branch name does not contain a valid semantic version. Current branch: $branchName "
61+ Write-Error "❌ ERROR: Failed to parse '$rawVersion' as a valid SemVer version."
6662 exit 1
6763 }
64+ echo "EXPECTED_VERSION=$expectedVersion" >> $env:GITHUB_ENV
6865
6966 - name : Parse and Compare Crate Versions
7067 shell : pwsh
71- env :
72- EXPECTED_VERSION : ${{ steps.extract_version.outputs.expected_version }}
7368 run : |
69+ Import-Module -Name PSSemVer -ErrorAction Stop
7470 try {
7571 $expectedSemVer = [PSSemVer]::Parse($env:EXPECTED_VERSION)
7672 } catch {
77- Write-Error "Expected version '$env:EXPECTED_VERSION' is not a valid semantic version."
73+ Write-Error "❌ ERROR: Expected version '$env:EXPECTED_VERSION' is not a valid semantic version."
7874 exit 1
7975 }
8076
81- # Retrieve package version using cargo pkgid
8277 $pkgid = cargo pkgid --quiet
83- if ($pkgid -match "#([\d\.]+) ") {
78+ if ($pkgid -match "#(.+)$ ") {
8479 $currentVersion = $matches[1]
8580 } else {
86- Write-Error "Failed to extract version from cargo pkgid output: $pkgid"
81+ Write-Error "❌ ERROR: Failed to extract version from cargo pkgid output: $pkgid"
8782 exit 1
8883 }
8984
90- Write-Host "Current crate version: $currentVersion"
91-
9285 try {
9386 $currentSemVer = [PSSemVer]::Parse($currentVersion)
9487 } catch {
95- Write-Error "Current version '$currentVersion' is not a valid semantic version."
88+ Write-Error "❌ ERROR: Current version '$currentVersion' is not a valid semantic version."
9689 exit 1
9790 }
9891
9992 if ($currentSemVer.CompareTo($expectedSemVer) -ne 0) {
100- Write-Error "ERROR: Crate version '$currentSemVer' does not match expected '$expectedSemVer'."
93+ Write-Error "❌ ERROR: Crate version '$currentSemVer' does not match expected '$expectedSemVer'."
10194 exit 1
102- } else {
103- Write-Host "Crate version '$currentSemVer' matches the branch version."
10495 }
10596
10697 publish-dry-run :
@@ -126,18 +117,18 @@ jobs:
126117
127118 - name : Install Rust
128119 shell : pwsh
129- run : rustup update stable && rustup default stable
120+ run : |
121+ rustup update stable
122+ rustup default stable
130123
131124 - name : Run Tests
132125 shell : pwsh
133126 run : |
134- echo "Running tests..."
135127 cargo test --all-targets
136128
137129 - name : Publish Dry-Run
138130 env :
139131 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
140132 shell : pwsh
141133 run : |
142- echo "Running cargo publish dry-run..."
143134 cargo publish --dry-run
0 commit comments