Last active
February 17, 2022 22:42
-
-
Save cdhunt/e3bd589481e2f3e9de4c23ed45519a3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I don't want to install Python so this docker image and Pwsh function mimic a binary | |
<# Dockerfile | |
FROM python:3-alpine | |
RUN pip install --upgrade cloudsmith-cli | |
WORKDIR /working | |
ENTRYPOINT ["cloudsmith"] | |
#> | |
function cloudsmith { | |
& docker run --rm -it ` | |
-v "$($PWD.Path):/working" ` | |
-v "$($env:LOCALAPPDATA)\cloudsmith:/root/.config/cloudsmith" ` | |
cloudsmith-cli:3-alpine ` | |
$args | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Package List | |
$names = gh api -X GET "/orgs/ORGNAME/packages" -F package_type=nuget --paginate | ConvertFrom-Json | select -exp Name | |
# Download all of the Packages | |
# The `dotnet nuget` command doesn't appear to have a raw download option. It wants to install it into a project. | |
$names | foreach-object { nuget install $_ -Source ProGet -DirectDownload -PackageSaveMode nupkg} | |
# Upload to CloudSmith | |
$names | %{ ls -path "$_*" -Directory } | | |
foreach-object { ls "$($_.FullName)\*.nupkg" | | |
foreach-object { nuget push $_.FullName -Source nuget -SkipDuplicate -ApiKey $api.GetNetworkCredential().Password}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$files = Get-ChildItem -Path C:\temp\zipfiles\ -Recurse -File | |
# Grab the version string from the filename | |
$pattern = [regex]'app-setup\.(\d{4}\.\d{1,2}\.\d{1,3}\.\d{1,3})(-pre-release)*\.zip' | |
foreach ($file in $files) { | |
$name = $file.Name | |
$folder = $file.FullName | Split-Path -Parent | Split-Path -Leaf | |
if ($file.Name -match $pattern) { | |
$version = $Matches[1] | |
# Check if it has a prerelease tag | |
if ($Matches.Count -eq 3) { | |
$version += $Matches[2] | |
} | |
cloudsmith push raw org/rawrepo $folder/$name --version $version -W --name enterprise-setup | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment