Skip to content

Commit

Permalink
chore: determine version from msbuild versionsuffix & versionprefix
Browse files Browse the repository at this point in the history
Signed-off-by: Sébastien DEGODEZ <sebastien.degodez@gmail.com>
  • Loading branch information
SebastienDegodez committed Nov 20, 2024
1 parent 8c47b7a commit 12740fc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: read
if: ${{ needs.build_test.outputs.publish-package != false && github.actor != 'dependabot[bot]' }}
if: ${{ needs.build_test.outputs.publish-package != false && github.actor != 'dependabot[bot]' && !needs.version.outputs.preReleaseTag }}
needs:
- commitlint
- version
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/steps.dotnet-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
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
Expand All @@ -23,18 +31,27 @@ jobs:
lfs: true
fetch-depth: 0

- name: 🛠️ Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '6.x'

- id: gitversion
name: 🏃 GitVersion
uses: gittools/actions/gitversion/execute@v3.0.0
with:
useConfigFile: true
- name: Read version from Directory.Build
id: gitversion
if: github.ref == 'refs/heads/main'
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 "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<Project>
<PropertyGroup>
<PackageId>$(AssemblyName)</PackageId>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>

<Description>Microcks.Testcontainers for .NET</Description>
<Authors>Sébastien DEGODEZ</Authors>
Expand Down
5 changes: 0 additions & 5 deletions GitVersion.yml

This file was deleted.

0 comments on commit 12740fc

Please sign in to comment.