Skip to content

Commit

Permalink
Merge branch 'improvements/SWRAP-1-SharpWrap2534-creation' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Walsh committed Nov 2, 2021
2 parents 509ff86 + f6becc2 commit 7fbaae9
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions SharpWrap2534Nuget/BuildNugetPkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import re
import time

# Store the args here and check if there's enough of them
args_array = sys.argv
Expand All @@ -15,7 +16,7 @@
# Arg 3 - Change Notes

# Store nuspec file and version value
template_nuspec_file = "NupkgConfig\\_SharpWrap2534.nuspec.base"
template_nuspec_file = ".\\NupkgConfig\\_SharpWrap2534.nuspec.base"
version_value = "<version>" + args_array[1] + "</version>"
version_tag_value = "<tags>" + args_array[2] + "</tags>"
if (len(args_array) == 3): changelog_contents = ""
Expand All @@ -37,24 +38,46 @@
input_nuspec_file.close()

# Write new values out and run the pack command.
output_spec_file = "SharpWrap2534_" + version_value + '.nuspec'
output_spec_file = ".\\SharpWrap2534_" + args_array[1] + '.nuspec'
history_spec_file = '.\\NupkgConfig\\SharpWrap2534_' + args_array[1] + '.nuspec'
if os.path.exists(output_spec_file): os.remove(output_spec_file)
if os.path.exists(history_spec_file): os.remove(history_spec_file)

# Write new ones out here.
with open (output_spec_file, "w") as nuspec_file:
nuspec_file.write(new_nuspec_contents)
nuspec_file.close()
with open (history_spec_file, "w") as history_nuspec_file:
history_nuspec_file.write(new_nuspec_contents)
history_nuspec_file.close()

# Run the pack command now.
print ('')
nuget_pack_command = 'nuget pack ' + output_spec_file + ' -OutputDirectory .\\NupkgOutput'
print ('Running nuget pack command: ' + nuget_pack_command)
os.popen(nuget_pack_command)
print ('Running nuget pack now...')
print ('--> Pack Command: ' + nuget_pack_command)
pack_stream = os.popen(nuget_pack_command)
print ('--> Packed Package OK!')

# Split output
print ('-------------------------------------------------------------')

# Push the package into the repo
nuget_package_file = '.\\NupkgOutput\\SharpWrap2534.' + version_value + '.nupkg'
nuget_push_command = 'nuget push ' + nuget_package_file + '-Source \"github\" -ConfigFile NupkgConfig\\_SharpWrap2534.nuget.config'
print ('Running nuget push command: ' + nuget_push_command)
os.popen(nuget_push_command)
nuget_package_file = '.\\NupkgOutput\\SharpWrap2534.' + args_array[1] + '.nupkg'
if os.path.exists(nuget_package_file): os.remove(nuget_package_file)

# Wait for settle.
time.sleep(1.5)
nuget_push_command = 'nuget push ' + nuget_package_file + ' -Source \"github\" -ConfigFile .\\NupkgConfig\\_SharpWrap2534.nuget.config -SkipDuplicate'
print ('Running nuget push now...')
print ('--> Push Command: ' + nuget_push_command)
push_stream = os.popen(nuget_push_command)
print ('--> Pushed to nuget OK!')

# Remove old files.
time.sleep(1.5)
if os.path.exists(output_spec_file): os.remove(output_spec_file)

# Split output
print ('-------------------------------------------------------------')
print ('-------------------------------------------------------------')
print ('')

0 comments on commit 7fbaae9

Please sign in to comment.