diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fae84f..79fa2bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: branches: [main] jobs: - build: + test: runs-on: ubuntu-latest permissions: contents: write @@ -98,3 +98,50 @@ jobs: git commit -m "Update coverage badges" git push origin coverage fi + + verify-frameworks: + runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: ['8.0', '9.0', '10.0'] + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup .NET SDKs + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 9.0.x + 10.0.x + + - name: Build Example Apps + run: | + dotnet build tests/SimpleBranchVersioning.ExampleApp -c Release + dotnet build tests/SimpleBranchVersioning.ConfiguredApp -c Release + + - name: Run ExampleApp + run: dotnet run --project tests/SimpleBranchVersioning.ExampleApp -f net${{ matrix.dotnet-version }} -c Release --no-build + + - name: Run ConfiguredApp + run: dotnet run --project tests/SimpleBranchVersioning.ConfiguredApp -f net${{ matrix.dotnet-version }} -c Release --no-build + + - name: Verify version.json + run: | + # ConfiguredApp should have version.json (GenerateVersionFile=true) + if [ ! -f "tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then + echo "::error::ConfiguredApp is missing version.json for net${{ matrix.dotnet-version }}" + exit 1 + fi + echo "ConfiguredApp version.json exists for net${{ matrix.dotnet-version }}" + cat tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json + + # ExampleApp should NOT have version.json (GenerateVersionFile=false by default) + if [ -f "tests/SimpleBranchVersioning.ExampleApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then + echo "::error::ExampleApp should not have version.json for net${{ matrix.dotnet-version }}" + exit 1 + fi + echo "ExampleApp correctly has no version.json for net${{ matrix.dotnet-version }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 492eddf..9ed0324 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,55 @@ on: - 'release/v*' jobs: + verify-frameworks: + runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: ['8.0', '9.0', '10.0'] + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup .NET SDKs + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 9.0.x + 10.0.x + + - name: Build Example Apps + run: | + dotnet build tests/SimpleBranchVersioning.ExampleApp -c Release + dotnet build tests/SimpleBranchVersioning.ConfiguredApp -c Release + + - name: Run ExampleApp + run: dotnet run --project tests/SimpleBranchVersioning.ExampleApp -f net${{ matrix.dotnet-version }} -c Release --no-build + + - name: Run ConfiguredApp + run: dotnet run --project tests/SimpleBranchVersioning.ConfiguredApp -f net${{ matrix.dotnet-version }} -c Release --no-build + + - name: Verify version.json + run: | + # ConfiguredApp should have version.json (GenerateVersionFile=true) + if [ ! -f "tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then + echo "::error::ConfiguredApp is missing version.json for net${{ matrix.dotnet-version }}" + exit 1 + fi + echo "ConfiguredApp version.json exists for net${{ matrix.dotnet-version }}" + cat tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json + + # ExampleApp should NOT have version.json (GenerateVersionFile=false by default) + if [ -f "tests/SimpleBranchVersioning.ExampleApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then + echo "::error::ExampleApp should not have version.json for net${{ matrix.dotnet-version }}" + exit 1 + fi + echo "ExampleApp correctly has no version.json for net${{ matrix.dotnet-version }}" + release: + needs: verify-frameworks runs-on: ubuntu-latest permissions: contents: write diff --git a/src/SimpleBranchVersioning/build/SimpleBranchVersioning.targets b/src/SimpleBranchVersioning/build/SimpleBranchVersioning.targets index 7600ffd..107a478 100644 --- a/src/SimpleBranchVersioning/build/SimpleBranchVersioning.targets +++ b/src/SimpleBranchVersioning/build/SimpleBranchVersioning.targets @@ -32,7 +32,7 @@ else - + $([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(OutputPath)', 'version.json')) @@ -75,7 +75,7 @@ else AfterTargets="GenerateVersionFile" DependsOnTargets="GenerateVersionFileInternal" BeforeTargets="GenerateNuspec;Pack" - Condition="'$(SetPackageVersionFromBranch)' == 'true'"> + Condition="'$(SetPackageVersionFromBranch)' == 'true' and '$(TargetFramework)' != ''"> @@ -86,7 +86,7 @@ else + Condition="'$(SetPackageVersionFromBranch)' == 'true' and '$(TargetFramework)' != ''"> $([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(OutputPath)', 'version.json')) diff --git a/tests/SimpleBranchVersioning.ConfiguredApp/SimpleBranchVersioning.ConfiguredApp.csproj b/tests/SimpleBranchVersioning.ConfiguredApp/SimpleBranchVersioning.ConfiguredApp.csproj index b809143..009b106 100644 --- a/tests/SimpleBranchVersioning.ConfiguredApp/SimpleBranchVersioning.ConfiguredApp.csproj +++ b/tests/SimpleBranchVersioning.ConfiguredApp/SimpleBranchVersioning.ConfiguredApp.csproj @@ -5,7 +5,7 @@ Exe - net10.0 + net8.0;net9.0;net10.0 true diff --git a/tests/SimpleBranchVersioning.ExampleApp/SimpleBranchVersioning.ExampleApp.csproj b/tests/SimpleBranchVersioning.ExampleApp/SimpleBranchVersioning.ExampleApp.csproj index 97e1f4b..f3cef7b 100644 --- a/tests/SimpleBranchVersioning.ExampleApp/SimpleBranchVersioning.ExampleApp.csproj +++ b/tests/SimpleBranchVersioning.ExampleApp/SimpleBranchVersioning.ExampleApp.csproj @@ -4,7 +4,7 @@ Exe - net10.0 + net8.0;net9.0;net10.0