Skip to content

Refactor BaseEntity properties and clean up using directives #100

Refactor BaseEntity properties and clean up using directives

Refactor BaseEntity properties and clean up using directives #100

name: Action to build and publish the project as a nuget package to github package registry
on:
push:
branches:
- main
paths:
- Sources/**
jobs:
build:
runs-on: ubuntu-latest
outputs:
Version: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 #fetch-depth is needed for GitVersion
#Install and calculate the new version with GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
id: gitversion # step id used as reference for output values
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
#Build/pack the project
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.x
- name: Build and Pack NuGet package
run: |
cd Sources
dotnet build --configuration Release
dotnet pack --configuration Release --output nupkg -p:Version='${{ steps.gitversion.outputs.SemVer }}'
- name: Upload NuGet package to GitHub
uses: actions/upload-artifact@v4
with:
name: nupkg
path: Sources/nupkg
release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' # only run job if on the master branch
steps:
#Push NuGet package to GitHub packages
- name: Download nuget package artifact
uses: actions/[email protected]
with:
name: nupkg
- name: Prep packages
run: dotnet nuget add source --username bvdcode --password ${{ secrets.DEPLOY_GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/bvdcode/index.json"
- name: Push package to GitHub packages
if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change
run: |
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ secrets.DEPLOY_GITHUB_TOKEN }} --source "github"
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json
#Create release
- name: Create Release
if: 1 == 0 #needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.Version }}
release_name: Release ${{ needs.build.outputs.Version }}
- name: Create Release
if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.build.outputs.Version }}
name: Release ${{ needs.build.outputs.Version }}
artifacts: "nupkg/*"
token: ${{ secrets.DEPLOY_GITHUB_TOKEN }}