Add RepositoryUrl
property to the project .csproj
file
<Project Sdk =" Microsoft.NET.Sdk" >
<PropertyGroup >
<TargetFramework >net5.0</TargetFramework >
<RepositoryUrl >https://github.com/PATH/TO/REPOSITORY</RepositoryUrl >
</PropertyGroup >
</Project >
Github Actions (.yml
file) should look like this
name : Build and Pack (push to github packages)
on :
push :
branches : [ master ]
pull_request :
branches : [ master ]
jobs :
build-Pack-Push :
runs-on : ubuntu-latest
permissions :
packages : write
contents : read
env :
PROJECT_NAME : # YOUR_PROJECT_NAME#
GITHUB_USER : # YOUR_GITHUB_USERNAME#
steps :
- name : Checkout
uses : actions/checkout@v2
with :
fetch-depth : 0
- name : Install GitVersion (by GitTools)
uses : gittools/actions/gitversion/setup@v0.9.10
with :
versionSpec : ' 5.x'
- name : Determine GitVersion
id : gitversion
uses : gittools/actions/gitversion/execute@v0.9.10
- name : Display Generated SemVer
run : |
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
- name : Setup .NET
uses : actions/setup-dotnet@v1
with :
dotnet-version : 5.0.x
- name : Restore dependencies
run : dotnet restore
- name : Build
run : dotnet build --configuration Release --no-restore
- name : Pack
run : dotnet pack --configuration Release --no-build --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name : Authenticate to Github Packages
run : dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --username ${{ env.GITHUB_USER }} --password ${{ github.token }} --store-password-in-clear-text --name github
- name : Push to github packages
run : dotnet nuget push ${{ env.PROJECT_NAME }}/bin/Release/*.nupkg -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k ${{ github.token }} --skip-duplicate