@@ -31,27 +31,28 @@ jobs:
3131 with :
3232 fetch-depth : 0
3333
34- - name : Compute version
34+ - name : Compute Version
3535 id : compute_version
36- shell : pwsh
37- env :
38- IS_TAG : ${{ startsWith(github.ref, 'refs/tags/v') }}
39- REF_NAME : ${{ github.ref_name }}
40- HEAD_COMMIT_TIMESTAMP : ${{ github.event.head_commit && github.event.head_commit.timestamp || '' }}
41- GITHUB_SHA : ${{ github.sha }}
36+ shell : bash
4237 run : |
43- if ($env:IS_TAG -eq 'true') {
44- $version = $env:REF_NAME
45- } elseif (-not [string]::IsNullOrEmpty($env:HEAD_COMMIT_TIMESTAMP)) {
46- $timestamp = [DateTime]::Parse($env:HEAD_COMMIT_TIMESTAMP).ToUniversalTime().ToString("yyyyMMddHHmm")
47- $version = "$timestamp-$($env:GITHUB_SHA)"
48- } else {
49- $timestamp = [DateTime]::UtcNow.ToString("yyyyMMddHHmm")
50- $version = "$timestamp-$($env:GITHUB_SHA)"
51- }
52-
53- "Version=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
54- "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
38+ # If this is a tag push and it starts with v, just use it
39+ if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
40+ Version="${GITHUB_REF#refs/tags/}"
41+ echo "version=$Version" >> $GITHUB_OUTPUT
42+ echo "detected tag push: $Version"
43+ exit 0
44+ fi
45+
46+ # Otherwise find the latest tag that starts with v
47+ LAST_TAG=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null || echo "v0.0.0")
48+
49+ # Compute a build number based on number of commits since that tag
50+ COMMITS_SINCE_TAG=$(git rev-list ${LAST_TAG}..HEAD --count)
51+
52+ # Final version: vX.Y.Z+<build>
53+ Version="${LAST_TAG}.${COMMITS_SINCE_TAG}"
54+ echo "version=$Version" >> $GITHUB_OUTPUT
55+ echo "no tag push; using $Version"
5556
5657 - name : Setup NuGet
5758 uses : NuGet/setup-nuget@v2
6869 run : msbuild build\SayMore.proj /t:Build /p:Configuration=$env:Configuration /p:Version=$env:Version /m
6970
7071 - name : Run tests
71- run : msbuild build\SayMore.proj /t:Test /p:Configuration=$env:Configuration /p:excludedCategories=SkipOnTeamCity /m
72+ run : msbuild build\SayMore.proj /t:Test /p:Configuration=$env:Configuration /p:useNUnit-x86=true /p: excludedCategories=SkipOnTeamCity /m
7273
7374 - name : Upload test results
7475 if : always()
0 commit comments