-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3db68ae
commit 1cde32a
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: 'Set Version' | ||
description: 'Set environment variables based on latest version' | ||
inputs: | ||
githubToken: | ||
description: 'the github token to use to fetch latest version' | ||
required: true | ||
default: '' | ||
overrideVersion: | ||
description: 'the version to force instead - overrides the latest version' | ||
required: false | ||
overrideRepository: | ||
description: 'the repository whose latest version is desired' | ||
required: false | ||
default: '' | ||
outputs: | ||
packageVersion: | ||
description: "the package version" | ||
value: "${{ steps.fetchversion.outputs.packageVersion }}" | ||
releaseVersion: | ||
description: "the release name / version" | ||
value: "${{ steps.fetchversion.outputs.releaseVersion }}" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- id: fetchversion | ||
run: | | ||
${{ github.action_path }}/Set-Version.ps1 ` | ||
-Repo "${{ inputs.overrideRepository || github.repository }}" ` | ||
-GithubToken "${{ inputs.githubToken }}" ` | ||
-ManualVersion "${{ inputs.overrideVersion }}" | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
$Repo, | ||
[Parameter(Mandatory = $true)] | ||
$GithubToken, | ||
$ManualVersion | ||
) | ||
$json = Invoke-WebRequest "https://api.github.com/repos/$Repo/releases/latest" ` | ||
-Headers @{ "Authorization" = "Token $GithubToken" } | ConvertFrom-Json | ||
$version = if ([string]::IsNullOrEmpty($ManualVersion)) { $json.tag_name.Trim("v") } else { $ManualVersion.Trim("v") } | ||
|
||
echo "releaseVersion=$($json.tag_name)" >> $env:GITHUB_OUTPUT | ||
echo "packageVersion=$version" >> $env:GITHUB_OUTPUT |