Skip to content

attempted fix

attempted fix #5

Workflow file for this run

name: Release
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .
# Build configuration and Platform.
BUILD_CONFIGURATION: Release
PLATFORM: x64
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository with tags
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures full history and tags are available
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
- name: Restore NuGet packages
run: nuget restore ${{ env.SOLUTION_FILE_PATH }}
- name: Build x64 Release
run: msbuild /m /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=${{ env.PLATFORM }} ${{ env.SOLUTION_FILE_PATH }}
- name: Determine version
id: version
shell: cmd
run: |
@echo off
REM Attempt to retrieve the latest tag (expected format: x.y.z). Suppress errors.
for /f "delims=" %%t in ('git describe --tags --abbrev=0 2^>nul') do set LATEST_TAG=%%t
if not defined LATEST_TAG (
echo No tag found. Defaulting to 0.0.0.
set "LATEST_TAG=0.0.0"
REM Count all commits. Subtract 1 so the first commit remains 0.0.0.
for /f %%i in ('git rev-list HEAD --count') do set ALL_COUNT=%%i
set /a COMMITS_SINCE=ALL_COUNT - 1
if %COMMITS_SINCE% lss 0 set COMMITS_SINCE=0
) else (
REM If a tag exists, count commits from that tag to HEAD.
for /f %%i in ('git rev-list %LATEST_TAG%..HEAD --count') do set COMMITS_SINCE=%%i
)
echo Latest tag: %LATEST_TAG%
echo Commits since latest tag: %COMMITS_SINCE%
REM If a tag exists other than the default base, compare its commit hash with HEAD.
if not "%LATEST_TAG%"=="0.0.0" (
for /f %%i in ('git rev-list -n 1 %LATEST_TAG%') do set TAG_COMMIT=%%i
for /f %%i in ('git rev-parse HEAD') do set CURRENT_COMMIT=%%i
echo Tag commit: %TAG_COMMIT%
echo Current commit: %CURRENT_COMMIT%
if "%TAG_COMMIT%"=="%CURRENT_COMMIT%" (
echo HEAD is tagged. Using existing version %LATEST_TAG%.
set "VERSION=%LATEST_TAG%"
goto WriteOutput
)
) else (
REM For our default base tag case, if no additional commits exist, remain at 0.0.0.
if "%COMMITS_SINCE%"=="0" (
set "VERSION=0.0.0"
goto WriteOutput
)
)
REM Otherwise, split LATEST_TAG (assumed in x.y.z format) into its parts.
for /f "tokens=1-3 delims=." %%a in ("%LATEST_TAG%") do (
set MAJOR=%%a
set MINOR=%%b
set PATCH=%%c
)
set /a NEW_PATCH=%PATCH% + %COMMITS_SINCE%
set "VERSION=%MAJOR%.%MINOR%.%NEW_PATCH%"
echo New version: %VERSION%
REM Create a lightweight tag (so no commit signature is required) and push it.
git tag %VERSION%
git push origin %VERSION%
:WriteOutput
REM Write the computed version to the GitHub Actions output environment file.
echo version=%VERSION%>> %GITHUB_OUTPUT%
- name: Rename release package with version
shell: cmd
run: |
REM Change directory to where the release package is located.
cd x64\release
REM Rename RekordBoxSongExporter.zip to include the version number.
ren RekordBoxSongExporter.zip RekordBoxSongExporter-${{ steps.version.outputs.version }}.zip