Update xunit-dotnet monorepo (#241) #198
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: ci-cd | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: | |
- created | |
concurrency: | |
group: ci-cd-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PROJECT_NAME: DrifterApps Seeds | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
check_changes: | |
uses: patmoreau/workflow-config/.github/workflows/check-changes-action.yml@main | |
with: | |
file_patterns: ${{ vars.CICD_CODE_FILE_PATTERNS }} | |
set-version: | |
runs-on: ubuntu-latest | |
needs: check_changes | |
if: > | |
(needs.check_changes.outputs.code_was_changed == 'true') || | |
(github.event_name == 'release' && github.event.action == 'created') | |
outputs: | |
version: ${{ steps.gitversion.outputs.majorMinorPatch }} | |
assembly-version: ${{ steps.gitversion.outputs.AssemblySemFileVer }} | |
nuget-version: ${{ steps.gitversion.outputs.NuGetVersionV2 }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Disable workflow commands | |
run: | | |
echo "::stop-commands::`echo -n ${{ github.token }} | sha256sum | head -c 64`" | |
- name: Ensure .NET Installed | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v1.1.1 | |
with: | |
versionSpec: "5.x" | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v1.1.1 | |
with: | |
useConfigFile: true | |
configFilePath: GitVersion.yml | |
- name: Display GitVersion outputs | |
run: | | |
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}" | |
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.AssemblySemFileVer }}" | |
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}" | |
- name: Enable workflow commands | |
run: | | |
echo "::`echo -n ${{ github.token }} | sha256sum | head -c 64`::" | |
build: | |
runs-on: ubuntu-latest | |
needs: set-version | |
env: | |
VERSION: ${{ needs.set-version.outputs.version }} | |
ASSEMBLY_VERSION: ${{ needs.set-version.outputs.assembly-version }} | |
NUGET_VERSION: ${{ needs.set-version.outputs.nuget-version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
env: | |
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- run: echo '${{ steps.stepid.outputs.dotnet-version }}' | |
- name: Restore packages | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration Release /property:Version=${{ env.ASSEMBLY_VERSION }} | |
- name: Tests | |
run: dotnet test --no-restore --no-build --configuration Release --logger 'trx;verbosity=normal' --results-directory ./tests-results --collect 'XPlat Code Coverage' | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
id: test-results | |
if: always() | |
with: | |
name: .Net Tests | |
path: ./tests-results/**/*.trx | |
reporter: dotnet-trx | |
- name: Set badge color | |
shell: bash | |
run: | | |
case ${{ steps.test-results.outputs.conclusion }} in | |
success) | |
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV | |
;; | |
failure) | |
echo "BADGE_COLOR=800000" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Create badge | |
uses: emibcn/badge-action@v2.0.3 | |
with: | |
label: Tests | |
status: "${{ steps.test-results.outputs.passed }} passed, ${{ steps.test-results.outputs.failed }} failed, ${{ steps.test-results.outputs.skipped }} skipped: ${{ steps.test-results.outputs.conclusion }}" | |
color: ${{ env.BADGE_COLOR }} | |
path: seeds-tests-badge.svg | |
- name: Upload badge to artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test Results Badge | |
path: | | |
seeds-tests-badge.svg | |
- name: Upload badge to Gist | |
if: > | |
(github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || | |
(github.event_name != 'workflow_run' && github.ref == 'refs/heads/main') | |
uses: exuanbo/actions-deploy-gist@v1 | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gist_id: 51a2fc9fd8b7ed500ed3b6aabe0fc2d6 | |
file_path: seeds-tests-badge.svg | |
file_type: text | |
tagging: | |
needs: [set-version, build] | |
uses: patmoreau/workflow-config/.github/workflows/tag-version.yml@main | |
with: | |
version: ${{ needs.set-version.outputs.version }} | |
publish: | |
needs: [set-version, tagging] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'created' | |
env: | |
VERSION: ${{ needs.set-version.outputs.version }} | |
ASSEMBLY_VERSION: ${{ needs.set-version.outputs.assembly-version }} | |
NUGET_VERSION: ${{ needs.set-version.outputs.nuget-version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
env: | |
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Restore packages | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration Release /property:Version=${{ env.ASSEMBLY_VERSION }} | |
- name: Pack NuGet packages | |
run: dotnet pack /property:Version=${{ env.NUGET_VERSION }} --no-build --include-symbols --configuration Release -o ./nuget-packages | |
- name: Publish Package | |
run: dotnet nuget push ./nuget-packages/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate | |
create_check: | |
needs: [check_changes, build] | |
uses: patmoreau/workflow-config/.github/workflows/create-check.yml@main | |
if: always() && needs.check_changes.result == 'success' | |
with: | |
code_was_changed: ${{ needs.check_changes.outputs.code_was_changed }} | |
check_name: 'build-completed' | |
check_result: ${{ needs.build.result }} |