How do I deploy nuget packages in Travis CI?

前端 未结 4 486
一个人的身影
一个人的身影 2021-02-08 03:14

I have a nuget package that runs Travis CI for its builds. Here is my yml:

language: csharp
solution: TreasureGen.sln
install:
  - nuget restore TreasureGen.sln         


        
4条回答
  •  攒了一身酷
    2021-02-08 03:36

    My .travis.yml is as below, it deploys correctly to nuget and only does the deploy from master branch. The NUGET_API environment variable is setup to only apply to master branch and not be visible in the build.

    language: csharp
    mono: none
    dotnet: 3.1
    before_install:
    - sudo apt-get -y install libpam0g-dev
    install:
    - dotnet restore
    script:
    - dotnet build -c Release
    after_success:
    - ./test/setup_test_account.sh
    - sudo dotnet test test/Npam.Tests/Npam.Tests.csproj
    before_deploy:
    - dotnet pack -c Release
    deploy:
      skip_cleanup: true
      provider: script
      script: dotnet nuget push ./src/Npam/bin/Release/Npam.*.nupkg  -k $NUGET_API -s https://api.nuget.org/v3/index.json
      on:
        branch: master
    

    https://github.com/CamW/npam/blob/master/.travis.yml

提交回复
热议问题