@@ -30,68 +30,77 @@ jobs:
3030 - name : Cache PowerShell Modules
3131 uses : actions/cache@v3
3232 with :
33- path : C:\Users\runneradmin\Documents\PowerShell\Modules
33+ path : |
34+ $env:USERPROFILE\Documents\WindowsPowerShell\Modules
3435 key : ${{ runner.os }}-powershell-modules
3536 restore-keys : ${{ runner.os }}-powershell-modules-
3637
3738 - name : Install Rust
3839 shell : pwsh
39- run : |
40- rustup update stable
41- rustup default stable
40+ run : rustup update stable && rustup default stable
4241
4342 - name : Install PSSemVer
4443 shell : pwsh
4544 run : |
46- if (-not (Get-Module -ListAvailable -Name PSSemVer)) {
45+ try {
46+ Import-Module -Name PSSemVer -ErrorAction Stop
47+ } catch {
48+ Write-Host "Installing PSSemVer module..."
4749 Install-Module -Name PSSemVer -Scope CurrentUser -Force -ErrorAction Stop
50+ Import-Module -Name PSSemVer -ErrorAction Stop
4851 }
49- Import-Module -Name PSSemVer -ErrorAction Stop
5052
5153 - name : Extract Branch Version
5254 id : extract_version
5355 shell : pwsh
5456 run : |
5557 $branchName = "${{ github.ref_name }}"
56- $rawVersion = $branchName -replace '^release/', ''
57- Import-Module -Name PSSemVer -ErrorAction Stop
5858 try {
59+ $rawVersion = $branchName -replace '^release/', ''
5960 $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"
6064 } catch {
61- Write-Error "❌ ERROR: Failed to parse '$rawVersion' as a valid SemVer version."
65+ Write-Error "Branch name does not contain a valid semantic version. Current branch: $branchName "
6266 exit 1
6367 }
64- echo "EXPECTED_VERSION=$expectedVersion" >> $env:GITHUB_ENV
6568
6669 - name : Parse and Compare Crate Versions
6770 shell : pwsh
71+ env :
72+ EXPECTED_VERSION : ${{ steps.extract_version.outputs.expected_version }}
6873 run : |
69- Import-Module -Name PSSemVer -ErrorAction Stop
7074 try {
7175 $expectedSemVer = [PSSemVer]::Parse($env:EXPECTED_VERSION)
7276 } catch {
73- Write-Error "❌ ERROR: Expected version '$env:EXPECTED_VERSION' is not a valid semantic version."
77+ Write-Error "Expected version '$env:EXPECTED_VERSION' is not a valid semantic version."
7478 exit 1
7579 }
7680
81+ # Retrieve package version using cargo pkgid
7782 $pkgid = cargo pkgid --quiet
78- if ($pkgid -match "#(.+)$ ") {
83+ if ($pkgid -match "#([\d\.]+) ") {
7984 $currentVersion = $matches[1]
8085 } else {
81- Write-Error "❌ ERROR: Failed to extract version from cargo pkgid output: $pkgid"
86+ Write-Error "Failed to extract version from cargo pkgid output: $pkgid"
8287 exit 1
8388 }
8489
90+ Write-Host "Current crate version: $currentVersion"
91+
8592 try {
8693 $currentSemVer = [PSSemVer]::Parse($currentVersion)
8794 } catch {
88- Write-Error "❌ ERROR: Current version '$currentVersion' is not a valid semantic version."
95+ Write-Error "Current version '$currentVersion' is not a valid semantic version."
8996 exit 1
9097 }
9198
9299 if ($currentSemVer.CompareTo($expectedSemVer) -ne 0) {
93- Write-Error "❌ ERROR: Crate version '$currentSemVer' does not match expected '$expectedSemVer'."
100+ Write-Error "ERROR: Crate version '$currentSemVer' does not match expected '$expectedSemVer'."
94101 exit 1
102+ } else {
103+ Write-Host "Crate version '$currentSemVer' matches the branch version."
95104 }
96105
97106 publish-dry-run :
@@ -117,18 +126,18 @@ jobs:
117126
118127 - name : Install Rust
119128 shell : pwsh
120- run : |
121- rustup update stable
122- rustup default stable
129+ run : rustup update stable && rustup default stable
123130
124131 - name : Run Tests
125132 shell : pwsh
126133 run : |
134+ echo "Running tests..."
127135 cargo test --all-targets
128136
129137 - name : Publish Dry-Run
130138 env :
131139 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
132140 shell : pwsh
133141 run : |
142+ echo "Running cargo publish dry-run..."
134143 cargo publish --dry-run
0 commit comments