diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml new file mode 100644 index 0000000..90c8944 --- /dev/null +++ b/.github/workflows/dotnet-build.yml @@ -0,0 +1,81 @@ +name: All packages build + +on: + push: + branches: [ main ] + pull_request: + branches: + - '**/*' + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + packages: write + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/workflows/parts/cache/ + + - name: Decode the Signing Key + # Generated via powershell: `[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('.\Refactoring.snk')) | Set-Clipboard` and saved to GitHub Secrets SIGNING_KEY + run: | + if [ -n "${{ secrets.SIGNING_KEY }}" ]; then + echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > ./Refactoring.snk + fi + + ########### + # BUILD + - name: Restore dependencies + run: dotnet restore + - name: Build + run: | + if [[ $VERSION_SUFFIX ]]; then + VERSION_SUFFIX_PARAM="--version-suffix sha.$VERSION_SUFFIX" + else + VERSION_SUFFIX_PARAM='' + fi + dotnet build --no-restore --configuration Release ${VERSION_SUFFIX_PARAM} + env: + VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} + + ########### + # TEST + - name: Test + run: | + if [[ $VERSION_SUFFIX ]]; then + VERSION_SUFFIX_PARAM="-p:VersionSuffix=sha.$VERSION_SUFFIX" + else + VERSION_SUFFIX_PARAM='' + fi + dotnet test --verbosity normal ${VERSION_SUFFIX_PARAM} --configuration Release --collect:"XPlat Code Coverage" + env: + VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} + - name: 'Upload Code Coverage' + uses: actions/upload-artifact@v4 + with: + name: code-coverage + path: ./lib/*/TestResults/*/coverage.cobertura.xml + retention-days: 7 + # - name: Record code coverage + # uses: 5monkeys/cobertura-action@master + # with: + # path: ./lib/*/TestResults/*/coverage.cobertura.xml + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # minimum_coverage: 90 + # fail_below_threshold: false + + ########### + # PUBLISH + - name: Publish NuGet packages to GitHub registry if new version number + if: ${{ github.ref != 'refs/heads/main' }} + run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --skip-duplicate --no-symbols + continue-on-error: true # Dependabot and other outside contributors can't push to our GitHub packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish NuGet packages to NuGet registry if new version number + if: ${{ github.ref == 'refs/heads/main' }} + run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/.github/workflows/parts/cache/action.yml b/.github/workflows/parts/cache/action.yml new file mode 100644 index 0000000..d4a6a23 --- /dev/null +++ b/.github/workflows/parts/cache/action.yml @@ -0,0 +1,19 @@ +name: 'Package Cache' +description: 'Caches packages for this repository' +inputs: {} +outputs: {} +runs: + using: 'composite' + steps: + # .NET install and cache + - uses: actions/setup-dotnet@v3 + with: + # The main version this project uses + dotnet-version: '10.0.x' + + - uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: | + ${{ runner.os }}-nuget- diff --git a/Directory.Build.Props b/Directory.Build.props similarity index 78% rename from Directory.Build.Props rename to Directory.Build.props index 224f457..9c5b078 100644 --- a/Directory.Build.Props +++ b/Directory.Build.props @@ -17,7 +17,7 @@ AnyCPU True - $(SolutionRoot)OpenApiCodegen.snk + $(SolutionRoot)Refactoring.snk $(NoWarn);CS8002;CA1054 @@ -33,14 +33,14 @@ - Dark Patterns Digital, Principle Studios, Matt DeKrey, Tony Mishler, Chris Lees - https://github.com/darkpatternsdigital/openapi-generators - https://github.com/darkpatternsdigital/openapi-generators.git + Dark Patterns Digital, Matt DeKrey + https://github.com/darkpatternsdigital/DarkPatterns.Refactoring + https://github.com/darkpatternsdigital/DarkPatterns.Refactoring.git git main true dpd-logo.png - 2026 Matt DeKrey; Dark Patterns Digital, LCA; & Principle Studios + 2026 Matt DeKrey; Dark Patterns Digital, LCA BSD-2-Clause README.md