-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpush.py
More file actions
38 lines (29 loc) · 1.22 KB
/
push.py
File metadata and controls
38 lines (29 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Chocolatey package version checking and packing of package
# Written by Hadrien Dussuel
# Before to run this script for the first time, register your API key on Chocolatey.
# Find the API KEY here: https://chocolatey.org/account
# Then enter this command as admin:
# choco setapikey -k yourAPIkey -s https://push.chocolatey.org/
import os
import subprocess
import glob
packages = os.listdir('src/')
print(packages)
for p in packages:
print("Checking versions -> " + p)
distantVersions = subprocess.getoutput('choco search --all -r ' + p).split('\n')
# Get the packed files
files = glob.glob("packed\\" + p + "*.nupkg")
for f in files:
versionFound = False
version = f.replace("packed\\" + p + ".", "").replace(".nupkg", "")
for v in distantVersions:
current = v.split("|")[1]
if(current == version):
versionFound = True
# If the version is not found, push it
if not versionFound:
print("Pushing -> " + p + " | " + version)
subprocess.getoutput('choco push ' + f)
subprocess.getoutput('git add src\\' + p + '\\latest.json')
subprocess.getoutput('git commit -m \"' + p + '|' + version + '\"')