add publish.py

This commit is contained in:
aozhiwei 2018-09-21 16:39:08 +08:00
parent 9f2ba7e438
commit f86d78fdca
2 changed files with 35 additions and 2 deletions

View File

@ -18,8 +18,8 @@ for proj in projects:
http_url_to_repo = proj['http_url_to_repo']
name = proj['name']
path = proj['namespace']['path']
if path != 'publish' or not ('game1008' in name):
continue
# if path != 'publish' or not ('game1008' in name):
# continue
if not os.path.exists('repository/%s' % path):
os.mkdir('repository/%s' % (path))
if not os.path.exists('repository/%s/%s' % (path, name)):
@ -27,6 +27,7 @@ for proj in projects:
os.system('cd repository/%s/%s && git pull' % (path, name))
os.system('cd repository/%s/%s && git submodule init' % (path, name))
os.system('cd repository/%s/%s && git submodule update' % (path, name))
continue
submodules = os.listdir('repository/%s/%s/third_party' % (path, name))
for module_name in submodules:
os.system('cd repository/%s/%s/third_party/%s && git checkout master && git pull' %

32
gitlab/publish.py Normal file
View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
import os
import sys
import json
import urllib.parse
import urllib.request
from optparse import OptionParser
def publish_project(project, tag):
# print(project_name, project_tag)
PUBLISH_URL = "http://10.10.3.16:5012/publisttest"
post_data = {
'project' : project,
'tag' : tag,
}
post_data = urllib.parse.urlencode(post_data).encode('ascii')
req = urllib.request.Request(PUBLISH_URL)
data = urllib.request.urlopen(req, post_data).readall()
print(data)
parser = OptionParser(usage="%prog [options]")
parser.add_option("-p",
"--projects",
action = "store",
type = "string",
dest = "projects",
help = "publish projects")
(options, args) = parser.parse_args()
if options.projects:
for project in options.projects.split(','):
project_name, project_tag = project.split('@')
publish_project(project_name, project_tag)