Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for overriding repository url, version and uploading multiple packages simultaneously using a glob pattern (wildcards) #53

Merged
merged 43 commits into from
Jun 17, 2020

Conversation

peters
Copy link
Collaborator

@peters peters commented Jun 12, 2020

  • Uploading a single .nupkg file
    gpr push your.nupkg -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}
    gpr push your.nupkg your.snupkg -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

  • Upload all .nupkg files in current working directory
    gpr push *.nupkg -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

  • Upload all .nupkg files in current working directory
    gpr push *.nupkg -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

  • Upload all .nupkg, .snupkg files in current working directory
    gpr push . -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

  • Upload recursively all .nupkg files found in current working directory
    gpr push **\**.nupkg -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

  • Upload recursively all .nupkg, .snupkg (symbol packages) files found in current working directory
    gpr push **\** -r ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}

Fixes #30
Fixes #47
Fixes #48
Fixes #50

/cc @jcansdale

Copy link
Owner

@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is very much appreciated, thank you! 🙏

I'm wondering if it would make sense to simplify this to take a repository ( e.g. OWNER/REPOSITORY) rather than a repository URL? That would make it easy to use ${{ github.repository }} in a publish workflow, which will probably be the most common configuration.

src/GprTool/NugetExtensions.cs Outdated Show resolved Hide resolved
src/GprTool/Program.cs Outdated Show resolved Hide resolved
src/GprTool/Program.cs Outdated Show resolved Hide resolved
src/GprTool/Program.cs Outdated Show resolved Hide resolved
…ushing nupkg to GPR. Fixes jcansdale#48

Update error message.

Remove dead code because there are no "xmlns" attributes to remove when instantiating a new XElement.

Rename file.

Refactor: Owner property is no longer required. Address feedback regarding --repository option that should be in the following format: owner/repository. This makes it trivial to change repository url in a github actions scenario: gpr push your.nupkg --repository ${{ github.repository }} -k ${{ secrets.GITHUB_TOKEN }}. I have added additional test cases that verifies that we only rewrite nuspec if repository url, repository type or version has been changed. /cc @jcansdale

Bugfix: Dispose nuspec context property.

Only attempt to parse version if repository option has been set.

Bugfix: Remove "_gpr.nupkg" prefix if nupkg is rewritten before uploading nupkg to GPR.

Rename class to XElementExtensions.
Copy link
Owner

@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way this is shaping out! If we could just check that either the .nupkg contains a repository element or the --repository option is defined. That would catch a load of user error and make the --repository option more discoverable. 😄

src/GprTool/NuGetUtilities.cs Outdated Show resolved Hide resolved
src/GprTool/Program.cs Outdated Show resolved Hide resolved
peters added 5 commits June 15, 2020 09:56
…ng the user to upload multiple packages simultaneously. Concurrency may be controlled via the optional "--concurrency" command.
… it's determined to be irrelevant (has no effect in the package upload process).
…om nupkg metadata. If value is invalid then inform user that they may override repository url using the --repository option.
@peters
Copy link
Collaborator Author

peters commented Jun 15, 2020

@jcansdale I've adressed your feedback :)

Copy link
Owner

@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits/suggested changes. 👍

src/GprTool/NuGetUtilities.cs Outdated Show resolved Hide resolved
src/GprTool/Program.cs Outdated Show resolved Hide resolved
test/GprTool.Tests/StringExtensions.cs Outdated Show resolved Hide resolved
…and uploading multiple packages in parallel. Concurrency can be controlled by the "--concurrency" option. Fixes jcansdale#30
@peters
Copy link
Collaborator Author

peters commented Jun 15, 2020

@jcansdale I merged #30 into this PR. I've also addressed your feedback. Much appreciated :)

@peters peters changed the title Add support for overriding repository url and version Add support for overriding repository url, version and uploading multiple packages simultaneously using a glob pattern (wildcards) Jun 15, 2020
@peters peters requested a review from jcansdale June 15, 2020 13:10
@jcansdale
Copy link
Owner

@peters it looks like we have a merge conflict. Can I leave that to you because I'll probably mess it up. 😉

# Conflicts:
#	src/GprTool/Program.cs
@peters
Copy link
Collaborator Author

peters commented Jun 15, 2020

@peters it looks like we have a merge conflict. Can I leave that to you because I'll probably mess it up. 😉

Hehe! 👯 Fixed in 1f417fd.

@jcansdale
Copy link
Owner

@peters I'm afraid I'm still seeing this:

$ dotnet run --project src/GprTool/GprTool.csproj push 'publish/**/*.nupkg' -k xxxxxx --repository jcansdale/packages
Unable to find any packages in directory /Users/jcansdale/git/github.com/jcansdale/gpr matching glob pattern: publish/**/*.nupkg. Valid filename extensions are .nupkg, .snupkg.

I'm guessing you're using Windows. Is it doing this on that?

@jcansdale
Copy link
Owner

I've fixed the, "Unable to find any packages in directory" error in 623bfce. It looks like we needed to use the a full path in the glob.

@peters
Copy link
Collaborator Author

peters commented Jun 16, 2020

I've fixed the, "Unable to find any packages in directory" error in 623bfce. It looks like we needed to use the a full path in the glob.

You are correct. I did some refactoring in order to handle both relative and absolute glob patterns in commit 04fd2b4

I've tested the following patterns on Windows. In the examples below, working directory is c:\github\gpr

gpr push . -r peters/gpr -k token -> c:\github\gpr\*.*
gpr push nupkg -r peters/gpr -k token -> c:\github\gpr\nupkg\*.*
gpr push ./nupkg -r peters/gpr -k token -> c:\github\gpr\nupkg\*.*
gpr push .\nupkg -r peters/gpr -k token -> c:\github\gpr\nupkg\*.*
gpr push nupkg/*.*-r peters/gpr -k token -> c:\github\gpr\nupkg\*.*
gpr push nupkg/**/*.nupkg -r peters/gpr -k token -> c:\github\gpr\nupkg\**\*.nupkg
gpr push nupkg/**/** -r peters/gpr -k token -> c:\github\gpr\nupkg\**\**
gpr push c:\github\gipr\nupkg/**/** -r peters/gpr -k token -> c:\github\gpr\nupkg\**\**

Test cases are available here: https://github.com/jcansdale/gpr/blob/8fd11e62f311d385efe71715ece8bef8056f7520/test/GprTool.Tests/IoExtensionsTests.cs

Copy link
Owner

@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great!

My last suggestion is to make the re-written package's extension .zip. This would be a simple way to prevent re-written packages being picked up by subsequent publishes.

For example, this happened in one of my tests:

$ dotnet run --project src/GprTool/GprTool.csproj push publish/system.threading.threadpool/4.0.10 --repository jcansdale/packages
Found 4 packages.
[System.Threading.ThreadPool.4.0.10_79a787939afb425bad2ec43d523b7a35_gpr.nupkg]: Repository url: https://github.com/jcansdale/packages. Version: 4.0.10. Size: 87957 bytes. 
[System.Threading.ThreadPool.4.0.10_8593de2577f6432e8ce0f86978d9fd21_gpr.nupkg]: Repository url: https://github.com/jcansdale/packages. Version: 4.0.10. Size: 87955 bytes. 
[System.Threading.ThreadPool.4.0.10_b40597b284c04a70b02ed302b5381d4d_gpr.nupkg]: Repository url: https://github.com/jcansdale/packages. Version: 4.0.10. Size: 87955 bytes. 
[System.Threading.ThreadPool.4.0.10_b40597b284c04a70b02ed302b5381d4d_gpr.nupkg]: Uploading package.
[System.Threading.ThreadPool.4.0.10_8593de2577f6432e8ce0f86978d9fd21_gpr.nupkg]: Uploading package.
[System.Threading.ThreadPool.4.0.10_79a787939afb425bad2ec43d523b7a35_gpr.nupkg]: Uploading package.
[System.Threading.ThreadPool.4.0.10.nupkg]: Repository url: https://github.com/jcansdale/packages. Version: 4.0.10. Size: 87958 bytes. 
[System.Threading.ThreadPool.4.0.10.nupkg]: Uploading package.
[System.Threading.ThreadPool.4.0.10_79a787939afb425bad2ec43d523b7a35_gpr.nupkg]: Error: Version System.Threading.ThreadPool of "4.0.10" has already been pushed.
[System.Threading.ThreadPool.4.0.10_8593de2577f6432e8ce0f86978d9fd21_gpr.nupkg]: Error: Version System.Threading.ThreadPool of "4.0.10" has already been pushed.
[System.Threading.ThreadPool.4.0.10.nupkg]: Error: Version System.Threading.ThreadPool of "4.0.10" has already been pushed.
[System.Threading.ThreadPool.4.0.10_b40597b284c04a70b02ed302b5381d4d_gpr.nupkg]: Error: Version System.Threading.ThreadPool of "4.0.10" has already been pushed.

I've marked this PR as ✅ , so merge at will. Thanks for this excellent contribution! 😄

src/GprTool/NuGetUtilities.cs Outdated Show resolved Hide resolved
@peters
Copy link
Collaborator Author

peters commented Jun 17, 2020

@jcansdale Build is green on Windows/Linux: https://github.com/peters/gpr/runs/778631740?check_suite_focus=true
You can go ahead and copy the workflow file if you want: https://github.com/peters/gpr/blob/master/.github/workflows/dotnetcore.yml

It would be useful if you could also add build badges: https://github.com/peters/gpr#gpr

One final request would be to enable dependabot so that nuget dependencies are updated (PR) automatically on a daily schedule.

Bonus: If you could enable prerelease versioning on PRs that would be awesome and it would be really easy to test new changes :)

image

@peters
Copy link
Collaborator Author

peters commented Jun 17, 2020

@jcansdale I updated the workflow file with OSX support. It should be as simple as copy-pasting the workflow file into this repository and we are good to go :)

Test are green on Windows, OSX and Linux: https://github.com/peters/gpr/runs/778786424?check_suite_focus=true

@peters
Copy link
Collaborator Author

peters commented Jun 17, 2020

LGTM 👍

@jcansdale jcansdale merged commit 7467f0d into jcansdale:master Jun 17, 2020
@jcansdale
Copy link
Owner

@peters It feels good to merge this PR! 🙏 🎈 👍

@peters
Copy link
Collaborator Author

peters commented Jun 17, 2020

@jcansdale Awesome! Thanks for excellent feedback reviews :)

@jcansdale
Copy link
Owner

@jcansdale I updated the workflow file with OSX support. It should be as simple as copy-pasting the workflow file into this repository and we are good to go :)

Thanks, I merged it in #58

@Swoorup
Copy link

Swoorup commented Nov 22, 2020

Just tried it out bulk uploading packages. This is pretty great and easy to use @peters
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants