Skip to content

Merge pull request #151 from samsmithnz/samsmithnz-patch-1 #378

Merge pull request #151 from samsmithnz/samsmithnz-patch-1

Merge pull request #151 from samsmithnz/samsmithnz-patch-1 #378

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build job
runs-on: windows-latest
outputs:
Version: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup 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
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: .NET test
run: dotnet test src/SatisfactoryTree.Tests/SatisfactoryTree.Tests.csproj -c Debug -e:CollectCoverage=true -e:CoverletOutput=TestResults/ -e:CoverletOutputFormat=lcov
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: src/SatisfactoryTree.Tests/TestResults/coverage.info
- name: .NET publish
run: dotnet publish src/SatisfactoryTree/SatisfactoryTree.csproj -c Release -p:Version='${{ steps.gitversion.outputs.SemVer }}'
- name: Upload package back to GitHub
uses: actions/upload-artifact@v4
with:
name: drop
path: src/SatisfactoryTree/bin/Release
sonarCloud:
name: Run SonarCloud analysis
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Run Sonarcloud test
uses: samsmithnz/SamsDotNetSonarCloudAction@v2
with:
projects: 'src/SatisfactoryTree/SatisfactoryTree.csproj,src/SatisfactoryTree.Tests/SatisfactoryTree.Tests.csproj,src/SatisfactoryTree.Web/SatisfactoryTree.Web.csproj'
dotnet-version: '8.0.x'
sonarcloud-organization: samsmithnz-github
sonarcloud-project: samsmithnz_SatisfactoryTree
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
release:
name: Release
runs-on: ubuntu-latest
needs:
- build
- sonarCloud
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Download the build artifacts
uses: actions/download-artifact@v4
- name: Display GitVersion outputs
run: |
echo "Version: ${{ needs.build.outputs.Version }}"
echo "CommitsSinceVersionSource: ${{ needs.build.outputs.CommitsSinceVersionSource }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: github.ref == 'refs/heads/main' && needs.build.outputs.CommitsSinceVersionSource > 0 #Only create a release if there has been a commit/version change
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: "v${{ needs.build.outputs.Version }}"
release_name: "v${{ needs.build.outputs.Version }}"