Skip to content

Continuous Integration #2220

Continuous Integration

Continuous Integration #2220

Workflow file for this run

name: Continuous Integration
on:
push:
branches:
- "master"
pull_request:
types: [opened, synchronize]
schedule:
- cron: "0 0 * * *"
env:
DOTNET_NOLOGO: "true"
CONFIGURATION: Release
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
GITHUB_PACKAGES_FEED_URL: https://nuget.pkg.github.com/cythral/index.json
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Get Commit Message
shell: bash
run: | # Account for pull request merge commits
sha=${{ github.sha }}
after=$(git rev-list origin/master..HEAD --max-parents=1 --max-count=1)
[ ! `git rev-list --no-walk --count --merges "$sha"` ] || sha=$after
echo "COMMIT_MESSAGE=$(git log --format=%B -n 1 $sha | tr '\n' ' ')" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Restore
run: dotnet restore
- name: Build
shell: bash
id: build
run: dotnet build --no-restore -m -bl:obj/logs/build-${{ matrix.os }}.binlog
- name: Test
run: dotnet test --no-build
- name: Upload Coverage
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./obj/Tests/Results/coverage.cobertura.xml
fail_ci_if_error: true
- name: Upload Nugets
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: nugets
path: bin/Packages/${{ env.CONFIGURATION }}
- name: Upload Logs
uses: actions/upload-artifact@v3
with:
name: logs-${{ matrix.os }}
path: obj/logs/
- name: Deploy to Github Packages
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push'
run: dotnet nuget push "bin/Packages/${CONFIGURATION}/*.nupkg" -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate --no-symbols
env:
FEED_TOKEN: ${{ secrets.GH_TOKEN }}
FEED_URL: ${{ env.GITHUB_PACKAGES_FEED_URL }}
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Build Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while building ${{ github.repository }} ${{ steps.build.outputs.version }} on ${{ matrix.os }}",
"color": 12720135
}
]
release:
needs: build
runs-on: ubuntu-latest
environment:
name: Production
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Download NuGets
uses: actions/download-artifact@v3
id: download-nugets
with:
name: nugets
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Deploy to NuGet
run: dotnet nuget push '${{ steps.download-nugets.outputs.download-path }}/*.nupkg' -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate
env:
FEED_TOKEN: ${{ secrets.NUGET_TOKEN }}
FEED_URL: ${{ env.NUGET_FEED_URL }}
- uses: ncipollo/release-action@v1
with:
artifacts: "${{ steps.download-nugets.outputs.download-path }}/*.nupkg,${{ steps.download-nugets.outputs.download-path }}/*.snupkg"
commit: ${{ github.sha }}
token: ${{ secrets.GH_TOKEN }}
tag: v${{ needs.build.outputs.version }}
prerelease: ${{ contains(needs.build.outputs.version, '-') }}
generateReleaseNotes: true
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Release Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while releasing ${{ github.repository }} ${{ needs.build.outputs.version }}",
"color": 12720135
}
]