Skip to content

fix: combine ci and release workflows #1197

fix: combine ci and release workflows

fix: combine ci and release workflows #1197

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: Run tests
run: dotnet test --collect:"XPlat Code Coverage" --logger "GitHubActions"
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage ${{ matrix.os }}
path: "**/coverage.cobertura.xml"
coverage:
name: Coverage
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v3
with:
name: Code coverage ubuntu-latest
path: coverage-ubuntu
- uses: actions/download-artifact@v3
with:
name: Code coverage windows-latest
path: coverage-windows
- uses: actions/download-artifact@v3
with:
name: Code coverage macos-latest
path: coverage-macos
- name: Generate coverage report
uses: danielpalme/[email protected]
with:
reports: "**/coverage.cobertura.xml"
targetdir: "coverage-report"
reporttypes: "Cobertura"
- name: Publish coverage report to Codacy
uses: codacy/codacy-coverage-reporter-action@master
if: github.repository == 'TestableIO/System.IO.Abstractions' && github.event_name == 'push'
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage-report/Cobertura.xml
pack:
name: Pack
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Create packages
run: dotnet pack --configuration Release --output ./packages
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
name: NuGet packages
path: packages/*.*
deploy:
name: Deploy
if: |
github.ref == 'refs/heads/main' &&
github.event_name == 'push' &&
(
startsWith(github.event.head_commit.message, 'feat:') ||
startsWith(github.event.head_commit.message, 'fix:') ||
contains(github.event.head_commit.message, 'breaking change')
)
needs: [pack]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v3
with:
name: NuGet packages
path: packages
- name: Push packages
run: dotnet nuget push "packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- uses: dotnet/[email protected]
id: nbgv
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.nbgv.outputs.SemVer2 }}
tag_name: v${{ steps.nbgv.outputs.SemVer2 }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
- name: Wait for GitHub release to be available
run: sleep 30s
shell: bash
- name: Comment on relevant PRs and issues
uses: apexskier/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
This is addressed in release {release_link}.
label-template: |
state: released