4343 gitVersion_InformationalVersion : ${{ steps.gitversion.outputs.GitVersion_InformationalVersion }}
4444 gitVersion_AssemblySemFileVer : ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }}
4545 base_version : ${{ steps.extract_base_version.outputs.version }}
46+ full_version : ${{ steps.extract_base_version.outputs.full_version }}
4647 build : ${{ steps.evaluate_build.outputs.result }}
4748 build_push : ${{ steps.evaluate_build_push.outputs.result }}
4849 build_configuration : ${{ steps.evaluate_build_configuration.outputs.result }}
@@ -64,20 +65,34 @@ jobs:
6465 versionSpec : " 6.x"
6566 preferLatestVersion : true
6667
67- - name : extract - base version from Dockerfile
68+ - name : extract - base version from Dockerfile and calculate version
6869 id : extract_base_version
6970 run : |
7071 BASE_VERSION=$(grep "^FROM ghcr.io/actions/actions-runner:" ${{ env.container_image_build_dockerfile }} | cut -d':' -f2)
7172 echo "Extracted base version: $BASE_VERSION"
7273 echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
74+
75+ # Calculate build number based on commits since last tag with this base version
76+ BUILD_NUMBER=1
77+ LAST_TAG=$(git tag --list "v${BASE_VERSION}+*" 2>/dev/null | sort -V | tail -1 || echo "")
78+ if [ -n "$LAST_TAG" ]; then
79+ # Extract the build number from the last tag and increment
80+ LAST_BUILD=$(echo "$LAST_TAG" | sed "s/v${BASE_VERSION}+//")
81+ BUILD_NUMBER=$((LAST_BUILD + 1))
82+ else
83+ # Count commits since we started using this base version
84+ BUILD_NUMBER=$(git rev-list --count HEAD 2>/dev/null || echo 1)
85+ fi
86+
87+ FULL_VERSION="${BASE_VERSION}+${BUILD_NUMBER}"
88+ echo "Full version with build metadata: $FULL_VERSION"
89+ echo "full_version=$FULL_VERSION" >> $GITHUB_OUTPUT
7390
7491 - name : gitversion - execute
7592 id : gitversion
7693 uses : gittools/actions/gitversion/execute@v4.0.1
7794 with :
7895 configFilePath : GitVersion.yaml
79- overrideConfig : |
80- next-version: ${{ steps.extract_base_version.outputs.version }}
8196
8297 - name : tools - detect changes
8398 id : pathsFilter
@@ -243,6 +258,7 @@ jobs:
243258 gitVersion_InformationalVersion : ${{ needs.discovery.outputs.gitVersion_InformationalVersion }}
244259 gitVersion_AssemblySemFileVer : ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
245260 base_version : ${{ needs.discovery.outputs.base_version }}
261+ full_version : ${{ needs.discovery.outputs.full_version }}
246262 steps :
247263 - name : tools - docker - login ghcr.io
248264 uses : docker/login-action@v3
@@ -272,11 +288,11 @@ jobs:
272288 uses : softprops/action-gh-release@v2
273289 with :
274290 repository : ${{ github.repository }}
275- name : v${{ env.gitVersion_InformationalVersion }}
276- tag_name : v${{ env.gitVersion_InformationalVersion }}
291+ name : v${{ env.full_version }}
292+ tag_name : v${{ env.full_version }}
277293 body : |
278294 Docker image version: `${{ env.base_version }}`
279- Release version: `${{ env.gitVersion_InformationalVersion }}`
295+ Release version: `${{ env.full_version }}`
280296
281297 The release process is automated.
282298 generate_release_notes : true
0 commit comments