diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d597c8d..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build artifacts - -# ==== NOTE: do not rename this yml file or the run_number will be reset ==== - -on: - push: - branches: - - main - - master - - develop - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - source-url: https://nuget.pkg.github.com/Shane32/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: Install dependencies - run: dotnet restore - - name: Build solution [Release] - run: dotnet build --no-restore -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER - - name: Pack solution [Release] - run: dotnet pack --no-restore --no-build -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER -o out - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: Nuget packages - path: out/* - - name: Publish Nuget packages to GitHub registry - run: dotnet nuget push "out/*" -k ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index df984b0..5ab4f63 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,65 +1,18 @@ name: Publish release on: + push: + branches: + - main + - master + - develop release: types: - published jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Check github.ref starts with 'refs/tags/' - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - run: | - echo Error! github.ref does not start with 'refs/tags' - echo github.ref: ${{ github.ref }} - exit 1 - - name: Set version number environment variable - env: - github_ref: ${{ github.ref }} - run: | - ref="${github_ref:10}" - echo $ref - echo "ref=$ref" >> $GITHUB_ENV - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - source-url: https://api.nuget.org/v3/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}} - - name: Install dependencies - run: dotnet restore - - name: Build solution [Release] - run: dotnet build --no-restore -c Release -p:Version=$ref - - name: Pack solution [Release] - run: dotnet pack --no-restore --no-build -c Release -p:Version=$ref -o out - - name: Publish artifacts - uses: actions/upload-artifact@v4 - with: - name: Nuget packages - path: out/* - - name: Publish Nuget packages to NuGet registry - run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}} - - name: Upload nuget packages as release artifacts - uses: actions/github-script@v2 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - console.log('environment', process.versions); - const fs = require('fs').promises; - const { repo: { owner, repo }, sha } = context; - - for (let file of await fs.readdir('out')) { - console.log('uploading', file); - - await github.repos.uploadReleaseAsset({ - owner, - repo, - release_id: ${{ github.event.release.id }}, - name: file, - data: await fs.readFile(`out/${file}`) - }); - } + publish: + uses: Shane32/SharedWorkflows/.github/workflows/publish-nuget.yml@v1 + with: + dotnet_folder: '.' + secrets: inherit diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5216b5b..7fc50e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,72 +2,16 @@ name: Run code tests on: pull_request: + push: + branches: + - main + - master + - develop jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout source - uses: actions/checkout@v4 - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - name: Install dependencies - run: dotnet restore - - name: Build solution [Debug] - run: dotnet build --no-restore - - name: Test solution [Debug] - run: > - dotnet test --no-restore --no-build --collect "XPlat Code Coverage" --results-directory . - -- - DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=lcov - # ==== code coverage reports ==== - - name: Move coverage file - shell: bash - run: find ./**/coverage.info -exec mv {} ./output.lcov.info \; - - name: Convert coverage report to clover & htmlsummary format - uses: danielpalme/ReportGenerator-GitHub-Action@4.7.1 - with: - reports: 'output.lcov.info' - targetdir: '.' - reporttypes: 'Clover;HtmlSummary' - tag: 'test_${{ github.run_number }}' - - name: Convert coverage report to html - uses: danielpalme/ReportGenerator-GitHub-Action@4.7.1 - with: - reports: 'output.lcov.info' - targetdir: './code_coverage' - reporttypes: 'Html' - tag: 'test_${{ github.run_number }}' - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: Test coverage reports - path: | - output.lcov.info - Clover.xml - code_coverage/** - summary.html - - name: Monitor coverage - if: ${{ github.event_name == 'pull_request' }} - uses: slavcodev/coverage-monitor-action@1.2.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - clover_file: "Clover.xml" - threshold_alert: 60 - threshold_warning: 80 - - format: - runs-on: ubuntu-latest - steps: - - name: Checkout source - uses: actions/checkout@v4 - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - name: Install dependencies - run: dotnet restore - - name: Check formatting - run: dotnet format --no-restore --verify-no-changes --severity error + build-check: + uses: Shane32/SharedWorkflows/.github/workflows/build-check.yml@v1 + with: + dotnet_folder: '.' + coveralls: true + secrets: inherit diff --git a/Shane32.TestHelpers.sln b/Shane32.TestHelpers.sln index 0d1966f..867524e 100644 --- a/Shane32.TestHelpers.sln +++ b/Shane32.TestHelpers.sln @@ -8,15 +8,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets global.json = global.json - README.md = README.md LICENSE = LICENSE + README.md = README.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "src\Tests\Tests.csproj", "{87DB4CC0-4AC3-4AC1-97FD-7C55D3B921D9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{1DAFDDB7-1BBC-4F75-BB8D-C6430F9DFA02}" ProjectSection(SolutionItems) = preProject - .github\workflows\build.yml = .github\workflows\build.yml .github\workflows\publish.yml = .github\workflows\publish.yml .github\workflows\tests.yml = .github\workflows\tests.yml EndProjectSection