diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml new file mode 100644 index 0000000..c53c0b7 --- /dev/null +++ b/.github/workflows/BuildAndTest.yml @@ -0,0 +1,155 @@ +name: Build and Test + +# PREREQUISITES FOR PUSH-BACK OF TEST RESULTS +# Please note: test project usually required nuget package JUnitTestLogger +# to be able to provide JUnit compatible test results XML file (required +# for pushing back details on succeeded/failed tests) +# +# NuGet install command: +# - Install-Package JUnitTestLogger + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [master] + pull_request: + branches: [master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + # Path to the solution file relative to the root of the project + SOLUTION_FILE_PATH: . + + # Configuration type to build + BUILD_CONFIGURATION: Debug + +jobs: + + test: + #needs: build + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + #arch: [x86, x86_64, arm] + os: [windows-latest, ubuntu-latest, macos-latest] + include: + - os: macos-latest + runNetExe: mono + # arch: x86_64 + #- os: ubuntu-latest + # arch: x86 + #- os: ubuntu-latest + # arch: x86_64 + #- os: ubuntu-latest + # arch: arm + #- os: windows-latest + # build_configuration_suffix: "_WIN" + # arch: x86 + #- os: windows-latest + # arch: x86_64 + + # the build-and-test job might be skipped, we don't need to run this job then + #if: success() || failure() + + env: + RESULTS_PATH: TestResults.xml + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Dir Listing (Win) + if: startsWith(matrix.os, 'windows') + run: dir + - name: Dir Listing (Linux/Mac) + if: (!startsWith(matrix.os, 'windows')) + run: ls -la + + - name: Install dependencies + run: dotnet restore /p:Configuration=${{env.BUILD_CONFIGURATION}}{{matrix.build_configuration_suffix}} + + - name: Build + run: dotnet build --configuration=${{env.BUILD_CONFIGURATION}}${{matrix.build_configuration_suffix}} --no-restore + + #- name: Run Unit Tests + # run: dotnet test --framework net8.0 --results-directory test-results --logger junit --configuration=${{env.BUILD_CONFIGURATION}}${{matrix.build_configuration_suffix}} --no-restore + + - name: Run Unit Tests (.NET Framework 4.8/Windows) + if: startsWith(matrix.os, 'windows') + run: dotnet test --framework net48 --results-directory test-results-net48 --logger junit --configuration=${{env.BUILD_CONFIGURATION}}${{matrix.build_configuration_suffix}} + + - name: Run Unit Tests (.NET/all platforms) + #if: (!startsWith(matrix.os, 'windows')) + run: dotnet test --framework net8.0 --results-directory test-results --logger junit --configuration=${{env.BUILD_CONFIGURATION}}${{matrix.build_configuration_suffix}} + + #- name: Dir Listing (Win) test-results + # if: startsWith(matrix.os, 'windows') + # run: dir test-results + #- name: Dir Listing (Linux/Mac) test-results + # if: (!startsWith(matrix.os, 'windows')) + # run: ls -la test-results + + - name: Unit Test Results (Win/Mac) (.NET Framework 4.8/Windows) + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + if: always() && (!(startsWith(matrix.os, 'ubuntu'))) + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: "test-results-net48/TestResults.xml" + check_run_annotations: all tests + comment_title: Unit Test Statistics (${{matrix.os}}) (.NET Framework 4.8/Windows) + check_name: Unit Test Results (${{matrix.os}}) (.NET Framework 4.8/Windows) + report_individual_runs: true + + - name: Unit Test Results (Linux) (.NET/all platforms) + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() && startsWith(matrix.os, 'ubuntu') + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: "test-results/TestResults.xml" + check_run_annotations: all tests + comment_title: Unit Test Statistics (${{matrix.os}}) (.NET/all platforms) + check_name: Unit Test Results (${{matrix.os}}) (.NET/all platforms) + report_individual_runs: true + + - name: Unit Test Results (Win/Mac) (.NET/all platforms) + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + if: always() && (!(startsWith(matrix.os, 'ubuntu'))) + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: "test-results/TestResults.xml" + check_run_annotations: all tests + comment_title: Unit Test Statistics (${{matrix.os}}) (.NET/all platforms) + check_name: Unit Test Results (${{matrix.os}}) (.NET/all platforms) + report_individual_runs: true + + #- name: Publish Unit Test Results + # uses: actions/upload-artifact@v4 + # if: always() + # with: + # name: NUnit Test Results ${{ matrix.os }} + # path: test-results/TestResults.xml + + - name: Publish Unit Test Results (.NET Framework 4.8/Windows) + uses: actions/upload-artifact@v4 + if: always() + with: + name: NUnit Test Results ${{ matrix.os }} - .NET Framework 4.8/Windows + path: "test-results-net48/TestResults.xml" + + - name: Publish Unit Test Results (.NET/all platforms) + uses: actions/upload-artifact@v4 + if: always() + with: + name: NUnit Test Results ${{ matrix.os }} - .NET/all platforms + path: "test-results/TestResults.xml" + diff --git a/.github/workflows/PublishRelease.yml b/.github/workflows/PublishRelease.yml new file mode 100644 index 0000000..030cc05 --- /dev/null +++ b/.github/workflows/PublishRelease.yml @@ -0,0 +1,190 @@ +name: Publish/Upload dotnet package on release + +# PLEASE NOTE: PUBLISHING/DEPLOYMENT +# Release is to be created manually at GitHub releases management page +# - release name usually contains "v1.2.3" +# After creating a GitHub release, following actions will automatically run: +# 1. NuGet package (version as defined in VS.Net project property "package version") +# 2. Attaching of compiled binaries to GitHub release + +on: + release: + types: [created] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + # Path to the solution file relative to the root of the project. + SOLUTION_FILE_PATH: . + + # Name of project configuration for build as well as name of the bin output subdirectory (both must match for "dotnet pack" to find compiled files!) + BUILD_CONFIGURATION: Debug + BUILD_OUTPUT_SUBDIR: Debug + PACK_CONFIGURATION: Debug + # Name of build project which creates required output for packaging/deployment + BUILD_PROJECT_01: PGK.Extensions/CompuMaster.PGK.Extensions.csproj + BUILD_PROJECT_02: PGK.Extensions.Entity/CompuMaster.PGK.Extensions.Entity.csproj + BUILD_PROJECT_03: PGK.Extensions.MVC/CompuMaster.PGK.Extensions.Entity.csproj + BUILD_PROJECT_04: PGK.Extensions.RhinoMocks/CompuMaster.PGK.Extensions.Entity.csproj + BUILD_PROJECT_05: PGK.Extensions.Web/CompuMaster.PGK.Extensions.Entity.csproj + BUILD_PROJECT_06: PGK.Extensions.Windows/CompuMaster.PGK.Extensions.Entity.csproj + BUILD_PROJECT_07: PGK.Extensions.Windows.Forms/CompuMaster.PGK.Extensions.Entity.csproj + # Name of directory (e.g. "bin") containing the subdirectory (e.g. "CI_CD") with all output files (*.dll) + BUILD_OUTPUT_BASEDIR_01: PGK.Extensions/bin + BUILD_OUTPUT_BASEDIR_02: PGK.Extensions.Entity/bin + BUILD_OUTPUT_BASEDIR_03: PGK.Extensions.MVC/bin + BUILD_OUTPUT_BASEDIR_04: PGK.Extensions.RhinoMocks/bin + BUILD_OUTPUT_BASEDIR_05: PGK.Extensions.Web/bin + BUILD_OUTPUT_BASEDIR_06: PGK.Extensions.Windows/bin + BUILD_OUTPUT_BASEDIR_07: PGK.Extensions.Windows.Forms/bin + # Name of project + PROJECT_NAME_01: CompuMaster.PGK.Extensions + PROJECT_NAME_02: CompuMaster.PGK.Extensions.Entity + PROJECT_NAME_03: CompuMaster.PGK.Extensions.MVC + PROJECT_NAME_04: CompuMaster.PGK.Extensions.RhinoMocks + PROJECT_NAME_05: CompuMaster.PGK.Extensions.Web + PROJECT_NAME_06: CompuMaster.PGK.Extensions.Windows + PROJECT_NAME_07: CompuMaster.PGK.Extensions.Windows.Forms + # BinariesZipName of project artifacts + ARTIFACTS_BIN_ZIP_01: bin-CM.PGK.Extensions.zip + ARTIFACTS_BIN_ZIP_02: bin-CM.PGK.Extensions.Entity.zip + ARTIFACTS_BIN_ZIP_03: bin-CM.PGK.Extensions.MVC.zip + ARTIFACTS_BIN_ZIP_04: bin-CM.PGK.Extensions.RhinoMocks.zip + ARTIFACTS_BIN_ZIP_05: bin-CM.PGK.Extensions.Web.zip + ARTIFACTS_BIN_ZIP_06: bin-CM.PGK.Extensions.Windows.zip + ARTIFACTS_BIN_ZIP_07: bin-CM.PGK.Extensions.Windows.Forms.zip + + +jobs: + publish: + runs-on: windows-latest + #if: false # always skip job + + env: + VersionPrefix: ${{ github.ref_name }} + + steps: + - name: GitHub Tag for assembly versioning + run: | + #echo "Tag name from GITHUB_REF_NAME: $GITHUB_REF_NAME" + echo "Tag name from github.ref_name: ${{ github.ref_name }}" + echo "Tag name from environment: ${{ env.VersionPrefix }}" + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Install dependencies + run: dotnet restore /p:Configuration=${{env.BUILD_CONFIGURATION}} + + - name: Build + run: dotnet build --configuration=${{env.BUILD_CONFIGURATION}} --no-restore + + - name: Zip binaries ${{env.PROJECT_NAME_01}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_01}} ${{env.BUILD_OUTPUT_BASEDIR_01}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_02}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_02}} ${{env.BUILD_OUTPUT_BASEDIR_02}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_03}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_03}} ${{env.BUILD_OUTPUT_BASEDIR_03}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_04}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_04}} ${{env.BUILD_OUTPUT_BASEDIR_04}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_05}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_05}} ${{env.BUILD_OUTPUT_BASEDIR_05}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_06}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_06}} ${{env.BUILD_OUTPUT_BASEDIR_06}}/${{env.BUILD_OUTPUT_SUBDIR}} + + - name: Zip binaries ${{env.PROJECT_NAME_07}} + run: Compress-Archive -DestinationPath ${{env.ARTIFACTS_BIN_ZIP_07}} ${{env.BUILD_OUTPUT_BASEDIR_07}}/${{env.BUILD_OUTPUT_SUBDIR}} + + + - name: Publish zipped binaries ${{env.PROJECT_NAME_01}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_01}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_02}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_02}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_03}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_03}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_04}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_04}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_05}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_05}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_06}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_06}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish zipped binaries ${{env.PROJECT_NAME_07}} + uses: softprops/action-gh-release@v1 + with: + files: ${{env.ARTIFACTS_BIN_ZIP_07}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + - name: Pack ${{env.PROJECT_NAME_01}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_01}} --output . + + - name: Pack ${{env.PROJECT_NAME_02}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_02}} --output . + + - name: Pack ${{env.PROJECT_NAME_03}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_03}} --output . + + - name: Pack ${{env.PROJECT_NAME_04}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_04}} --output . + + - name: Pack ${{env.PROJECT_NAME_05}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_05}} --output . + + - name: Pack ${{env.PROJECT_NAME_06}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_06}} --output . + + - name: Pack ${{env.PROJECT_NAME_07}} + run: dotnet pack --no-build --configuration=${{env.PACK_CONFIGURATION}} ${{env.BUILD_PROJECT_07}} --output . + + + - name: PushNuget ${{env.PROJECT_NAME_01}} + ${{env.PROJECT_NAME_02}} + ${{env.PROJECT_NAME_03}} + ${{env.PROJECT_NAME_04}} + ${{env.PROJECT_NAME_05}} + ${{env.PROJECT_NAME_06}} + ${{env.PROJECT_NAME_07}} + run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate + + - name: Publish Package Artifacts + uses: actions/upload-artifact@v4 + with: + name: Nupkg Artifacts + path: ./**/*.nupkg \ No newline at end of file diff --git a/CompuMaster.PGK.Extensions.sln b/CompuMaster.PGK.Extensions.sln index 2db8aad..0d14981 100644 --- a/CompuMaster.PGK.Extensions.sln +++ b/CompuMaster.PGK.Extensions.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompuMaster.PGK.Extensions. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6F63218A-D300-44A8-98B2-D14D2B4D84F7}" ProjectSection(SolutionItems) = preProject + .github\workflows\BuildAndTest.yml = .github\workflows\BuildAndTest.yml + .github\workflows\PublishRelease.yml = .github\workflows\PublishRelease.yml README.md = README.md EndProjectSection EndProject