brandedoutcast / publish-nuget

📦 GitHub action to automate publishing NuGet packages when project version changes
https://github.com/marketplace/actions/publish-nuget
MIT License
197 stars 102 forks source link

[FEATURE] Multiple Nuget Deploy, 1 Step #41

Open houseofcat opened 3 years ago

houseofcat commented 3 years ago

First of thanks for creating this action, I am using the pants off of it right now.

This seems like a straightforward request that I am surprised it hasn't been solved (that I could find with Googling a way to do this).

Would rather create a step that I supply a directory and we just recursively find all .CSPROJ and pack/push them with the same configuration and continue-on-error true.

Providing my current workflow as there maybe a way to do this that I just can't seem to find the instructions for.

https://github.com/houseofcat/Library/blob/master/.github/workflows/nuget-publish.yml

AraHaan commented 3 years ago

I would rather do this instead:

    - name: Publish Release      
      id: publish_nuget
      uses: brandedoutcast/publish-nuget@master
      continue-on-error: true
      with:
        # Filepath of the project to be packaged, relative to root of repository
        PROJECT_FILE_PATH: **/*.csproj
        # Flag to toggle git tagging, enabled by default
        TAG_COMMIT: false
        # API key to authenticate with NuGet server
        NUGET_KEY: ${{ secrets.NUGET_API_KEY }}
        INCLUDE_SYMBOLS: false
AraHaan commented 3 years ago

Merged into my fork test it out with Elskom/publish-nuget@main

AraHaan commented 3 years ago

Got this working by doing amends and force pushes all day and running CI over and over again until it started working like I wanted:

Run Elskom/publish-nuget@main
executing: [dotnet nuget list source]
Registered Sources:
  1.  xunit-prereleases [Enabled]
      https://www.myget.org/F/xunit/api/v3/index.json
  2.  nuget.org [Enabled]
      https://api.nuget.org/v3/index.json

executing: [dotnet nuget enable source nuget.org]
Package source with Name: nuget.org enabled successfully.

Project Filepath: src/Elskom.GitInformation/Elskom.GitInformation.csproj
Version Filepath: src/Elskom.GitInformation/Elskom.GitInformation.csproj
Version Regex: /^\s*<Version>(.*)<\/Version>\s*$/m
Version: 1.0.0
Package Name: Elskom.GitInformation
Project Filepath: src/GitBuildInfo.SourceGenerator/GitBuildInfo.SourceGenerator.csproj
Version Filepath: src/GitBuildInfo.SourceGenerator/GitBuildInfo.SourceGenerator.csproj
Version Regex: /^\s*<Version>(.*)<\/Version>\s*$/m
Version: 1.0.10
Package Name: GitBuildInfo.SourceGenerator
Status code: 404: Not Found
No packages found. Pushing initial version...
✨ found new version (1.0.0) of Elskom.GitInformation
NuGet Source: https://api.nuget.org
executing: [dotnet nuget push artifacts/Elskom.GitInformation.1.0.0.nupkg -s nuget.org -k *** --skip-duplicate]
Pushing Elskom.GitInformation.1.0.0.nupkg to 'https://www.nuget.org/api/v2/package'...
  PUT https://www.nuget.org/api/v2/package/
  Created https://www.nuget.org/api/v2/package/ 852ms
Your package was pushed.

Status code: 200: OK
This version is new, pushing...
✨ found new version (1.0.10) of GitBuildInfo.SourceGenerator
NuGet Source: https://api.nuget.org
executing: [dotnet nuget push artifacts/GitBuildInfo.SourceGenerator.1.0.10.nupkg -s nuget.org -k *** --skip-duplicate]
Pushing GitBuildInfo.SourceGenerator.1.0.10.nupkg to 'https://www.nuget.org/api/v2/package'...
  PUT https://www.nuget.org/api/v2/package/
  Created https://www.nuget.org/api/v2/package/ 1194ms
Your package was pushed.

However my fork is a breaking change from this version, for starters I was forced to strip automatic build and pack into it's own action which can actually do a lot more than just build and pack like run unit tests. If interested I gutted that logic out into https://github.com/Elskom/build-dotnet/

Also the old INCLUDE_SYMBOLS input and other bits was removed for the msbuild project properties that the .NET Core CLI program (including the dotnet nuget pack) respects being set and would push the symbol package when those are set. As such I thought it's worth removing it from the action due to that feature.