broken gitignore and missing files because of it #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 # Ensure full history (and tags) is 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 and create tag if needed | |
id: version | |
shell: cmd | |
run: | | |
@echo off | |
REM Retrieve the latest tag (assumes tags are in x.y.z format) | |
for /f "delims=" %%t in ('git describe --tags --abbrev=0') do set LATEST_TAG=%%t | |
echo Latest tag: %LATEST_TAG% | |
REM Get the commit hash for the latest tag and for the HEAD | |
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%" | |
) else ( | |
REM Count commits since the latest tag. | |
for /f %%i in ('git rev-list %LATEST_TAG%..HEAD --count') do set COMMITS_SINCE=%%i | |
echo Commits since tag: %COMMITS_SINCE% | |
REM Split LATEST_TAG into MAJOR, MINOR, and PATCH. | |
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 an annotated tag and push it. | |
git tag -a %VERSION% -m "Auto-incremented tag %VERSION%" | |
git push origin %VERSION% | |
) | |
REM Write the version to the GitHub environment file for outputs. | |
REM Using the new environment file approach (no longer using set-output). | |
echo version=%VERSION%>> %GITHUB_OUTPUT% | |
- name: Rename release package with version | |
shell: cmd | |
run: | | |
REM Change to the folder where the release package is generated. | |
cd x64\release | |
REM Rename "RekordBoxSongExporter.zip" to include the version. | |
ren RekordBoxSongExporter.zip RekordBoxSongExporter-${{ steps.version.outputs.version }}.zip |