Skip to content

Instantly share code, notes, and snippets.

@mjebrahimi
Last active April 15, 2020 14:33
Show Gist options
  • Save mjebrahimi/1c12f2f9968a16e2984d0867468cd4ec to your computer and use it in GitHub Desktop.
Save mjebrahimi/1c12f2f9968a16e2984d0867468cd4ec to your computer and use it in GitHub Desktop.
Gtihub action .yaml file for .NET Core libraries
name: .NET Core
on:
push:
paths-ignore:
- 'readme.md'
pull_request:
paths-ignore:
- 'readme.md'
jobs:
build:
runs-on: ubuntu-latest
# runs-on: $
# strategy:
# matrix:
# os: [macOS-latest, ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
# if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest'
- name: Build (Release)
run: dotnet build --configuration Release
- name: Test (Release)
run: dotnet test --configuration Release
- name: Pack (Release)
run: dotnet pack src --configuration Release
- name: Publish
if: github.event_name == 'push'
run: |
if ( "${{github.ref}}" -match "^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$" ) {
dotnet nuget push src\bin\Release\*.nupkg -s nuget.org -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json
} else {
echo "publish is only enabled by tagging with a release tag"
}
@mjebrahimi
Copy link
Author

By desabling symbol file (.snupkg not generated) when you want to push nuget package with command dotnet nuget push *.nupkg will receive an error File does not exist (*.snupkg) to resolve this you must add --no-symbols true like below

> dotnet nuget push *.nupkg -s nuget.org -k ****** --no-symbols true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment