-
-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (49 loc) · 2.11 KB
/
steps.dotnet-version.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
on:
workflow_call:
inputs:
runs-on:
required: false
type: string
default: 'ubuntu-latest'
outputs:
version:
description: 'The version based on git history (gitversion)'
value: ${{ jobs.define_version.outputs.version }}
preReleaseTag:
description: 'preReleaseTag (gitversion)'
value: ${{ jobs.define_version.outputs.preReleaseTag }}
majorMinorPatch:
description: 'majorMinorPatch (gitversion)'
value: ${{ jobs.define_version.outputs.majorMinorPatch }}
jobs:
define_version:
runs-on: ${{ inputs.runs-on }}
outputs:
version: ${{ steps.gitversion.outputs.fullSemVer }}
preReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}
majorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
steps:
- name: 🔄 Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Read version from Directory.Build
id: gitversion
run: |
[xml]$xml = Get-Content -Path .\Directory.Build.props
$majorMinorPatch = ([string]$xml.Project.PropertyGroup.VersionPrefix).Trim()
if (-not [string]::IsNullOrEmpty($majorMinorPatch)) { $majorMinorPatch = $majorMinorPatch.Trim() }
echo "majorMinorPatch=$majorMinorPatch" >> $env:GITHUB_OUTPUT
$preReleaseTag = ([string]$xml.Project.PropertyGroup.VersionSuffix).Trim()
if (-not [string]::IsNullOrEmpty($preReleaseTag)) { $preReleaseTag = $preReleaseTag.Trim() }
echo "preReleaseTag=$preReleaseTag" >> $env:GITHUB_OUTPUT
$fullSemVer = $majorMinorPatch
if ([string]::IsNullOrEmpty($preReleaseTag) -eq $false) { $fullSemVer = "$majorMinorPatch-$preReleaseTag.$env:GITHUB_RUN_NUMBER" }
echo "fullSemVer=$fullSemVer" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"