Skip to content

Commit 3adbd71

Browse files
Updated action to output version properly
1 parent 12cacff commit 3adbd71

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
---
88

9+
## [[0.0.2.0]](https://github.com/mod-posh/GetProjectVersion/releases/tag/v0.0.2.0) - 2024-07-17
10+
11+
There was a problem with accessing the output of the action, this should be resolved with this release.
12+
13+
What's Changed:
14+
15+
1. **PowerShell Script (`getprojectversion.ps1`)**:
16+
- Corrected the variable name for `$Filename` in `Join-Path`.
17+
- Ensured `Write-Output` is used instead of `return` to properly capture the output for the calling environment.
18+
19+
2. **GitHub Action YAML (`action.yml`)**:
20+
- Used `echo "Version=$Version" >> $GITHUB_ENV` to correctly set the environment variable for the output in GitHub Actions.
21+
- Ensured the PowerShell script path is correctly formatted for cross-platform compatibility by wrapping the path in double quotes.
22+
923
## [[0.0.1.7]](https://github.com/mod-posh/GetProjectVersion/releases/tag/v0.0.1.7) - 2024-01-18
1024

1125
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: [GitHub Actions: Deprecating save-state and set-output commands](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)

action.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ inputs:
2020
runs:
2121
using: 'composite'
2222
steps:
23-
- name: Checkout Repository
24-
uses: actions/checkout@v3
25-
2623
- name: Get Project Version
2724
env:
28-
VERBOSE: ${{ inputs.verbose }}
25+
VERBOSE: ${{ inputs.verbose }}
2926
run: |
30-
$Version = & $env:GITHUB_ACTION_PATH\\getprojectversion.ps1 -Filename ${{ inputs.Filename }}
31-
echo "{Version}={$Version}" >> $GITHUB_OUTPUT
27+
$Version = & "$env:GITHUB_ACTION_PATH/getprojectversion.ps1" -Filename "${{ inputs.Filename }}"
28+
echo "Version=$Version" >> $GITHUB_ENV
3229
shell: pwsh
3330
id: GetProjectVersion

getprojectversion.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
param (
22
[string]$Filename
33
)
4-
try {
4+
try
5+
{
56
$ErrorActionPreference = 'Stop';
67
$Error.Clear();
78
$verbose = $env:VERBOSE
89

910
$runnerPath = $env:GITHUB_WORKSPACE
10-
$sourcePath = Join-Path -Path $runnerPath -ChildPath $FileName
11+
$sourcePath = Join-Path -Path $runnerPath -ChildPath $Filename
1112

1213
if ($verbose.ToLower() -eq 'verbose')
1314
{
@@ -42,8 +43,10 @@ try {
4243
Write-Host "Version : $($Version)"
4344
}
4445

45-
return $Version
46-
} catch {
46+
Write-Output $Version
47+
}
48+
catch
49+
{
4750
$_.InvocationInfo | Out-String
4851
throw $_.Exception.Message;
49-
}
52+
}

0 commit comments

Comments
 (0)