From 202175f2a7ae2feb26c2718630699936f981b522 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Fri, 22 Aug 2014 23:26:03 +0200 Subject: [PATCH 01/14] First appveyor script and python windows package build file --- appveyor.yml | 88 +++++++++++++++++++++++ projects/mtg/bin/Res/createResourceZip.py | 33 +++++---- projects/mtg/bin/createWindowsZip.py | 80 +++++++++++++++++++++ 3 files changed, 186 insertions(+), 15 deletions(-) create mode 100644 appveyor.yml create mode 100644 projects/mtg/bin/createWindowsZip.py diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..7413b4ad6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,88 @@ +# Notes: +# - Minimal appveyor.yml file is an empty file. All sections are optional. +# - Indent each level of configuration with 2 spaces. Do not use tabs! +# - All section names are case-sensitive. +# - Section names should be unique on each level. + +#---------------------------------# +# environment configuration # +#---------------------------------# + +# environment variables +environment: +# environment: +# global: +# connection_string: server=12;password=13; +# service_url: https://127.0.0.1:8090 +# +# matrix: +# - db: mysql +# provider: mysql +# +# - db: mssql +# provider: mssql +# password: +# secure: $#(JFDA)jQ@#$ + +# scripts that run after cloning repository +install: + - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py') + - "%PYTHON%/python.exe C:/get-pip.py" + - "%PYTHON%/Scripts/pip.exe install pyjavaproperties" + +#---------------------------------# +# build configuration # +#---------------------------------# + +# build Configuration, i.e. Debug, Release, etc. +configuration: Release + +build: + project: projects/mtg/mtg_vs2010.sln # path to Visual Studio solution or project + +#---------------------------------# +# tests configuration # +#---------------------------------# + +# to disable automatic tests +test: off + + +#---------------------------------# +# artifacts configuration # +#---------------------------------# + +artifacts: + # pushing windows package + - path: projects\mtg\bin\Wagic-windows*.zip + + +#---------------------------------# +# deployment configuration # +#---------------------------------# + +# scripts to run before deployment +before_deploy: +- cd projects/mtg/bin +- "%PYTHON%/python.exe createWindowsZip.py" + +# scripts to run after deployment +after_deploy: + +# to run your custom scripts instead of provider deployments +deploy_script: + +# to disable deployment +#deploy: off + +#---------------------------------# +# global handlers # +#---------------------------------# + +# on successful build +on_success: + - do something + +# on build failure +on_failure: + - do something diff --git a/projects/mtg/bin/Res/createResourceZip.py b/projects/mtg/bin/Res/createResourceZip.py index ff5ed73d5..baf5eab1f 100644 --- a/projects/mtg/bin/Res/createResourceZip.py +++ b/projects/mtg/bin/Res/createResourceZip.py @@ -30,8 +30,8 @@ def createResZipFile(filename): zip_file.close() if rename: - os.rename('settings/options.txt', 'settings/options.orig.txt') - os.rename('player/options.txt', 'player/options.orig.txt') + os.rename('settings/options.txt', 'settings/options.orig.txt') + os.rename('player/options.txt', 'player/options.orig.txt') def getFilename(): p = Properties(); @@ -44,16 +44,18 @@ def getFilename(): -def createStandardResFile(): - print "Creating Standard Resource File" - filename = getFilename() + '.zip' +def createStandardResFile(filename): + print('Creating Standard Resource File') + if not filename: + filename = getFilename() + '.zip' createResZipFile( filename ) print >> sys.stderr, 'Created Resource Package for Standard Distribution: {0}'.format( filename) -def createIosResFile(): - print 'Preparing Resource Package for iOS' +def createIosResFile(filename): + print('Preparing Resource Package for iOS') utilities = ZipUtilities() - filename = getFilename() + '_iOS.zip' + if not filename: + filename = getFilename() + '_iOS.zip' #createResZipFile( filename ) zip_file = zipfile.ZipFile(filename, 'a', zipfile.ZIP_STORED) zip_file.write("../../iOS/Res/rules/modrules.xml", "rules/modrules.xml", zipfile.ZIP_STORED) @@ -78,10 +80,10 @@ class ZipUtilities: if file != '.svn': full_path = os.path.join(folder, file) if os.path.isfile(full_path): - print 'File added: ' + str(full_path) + print('File added: ' + str(full_path)) zip_file.write(full_path) elif os.path.isdir(full_path): - print 'Entering folder: ' + str(full_path) + print('Entering folder: ' + str(full_path)) self.addFolderToZip(zip_file, full_path) @@ -90,16 +92,17 @@ def main(): parser = OptionParser() parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform") + parser.add_option("-n", "--name", help="NAME: specify resource file name", metavar="NAME", dest="name") (options, args) = parser.parse_args() if (options.platform): - if (options.platform == "ios"): - createIosResFile() - else: - createStandardResFile() + if (options.platform == "ios"): + createIosResFile(options.name) + else: + createStandardResFile(options.name) else: - createStandardResFile() + createStandardResFile(options.name) if __name__ == "__main__": main() diff --git a/projects/mtg/bin/createWindowsZip.py b/projects/mtg/bin/createWindowsZip.py new file mode 100644 index 000000000..f550bdaf5 --- /dev/null +++ b/projects/mtg/bin/createWindowsZip.py @@ -0,0 +1,80 @@ +import sys +import os +import zipfile +from pyjavaproperties import Properties +from optparse import OptionParser + +def createWindowsZipFile(filename): + utilities = ZipUtilities() + zip_file = zipfile.ZipFile(filename, 'w', zipfile.ZIP_STORED) + zip_file.write('../../../LICENSE') + zip_file.write('libpng13.dll') + zip_file.write('SDL.dll') + zip_file.write('fmod.dll') + zip_file.write('zlib1.dll') + zip_file.write('Wagic.exe') + zip_file.write('Res/' + getFilename('core') + '.zip') + zip_file.close() + +def getFilename(filename): + p = Properties(); + p.load(open('../build.number.properties')); + minor = p['build.minor']; + major = p['build.major']; + point = p['build.point']; + filename = filename + '-' + major + minor + point + return filename + +def createStandardResFile(): + print "Creating Resource File" + cmd = 'python createResourceZip.py -n ' + getFilename('core') + '.zip' + os.chdir("Res") + os.system(cmd) +# os.system("python createResourceZip.py -n resources.zip") + os.chdir("..") + print "Creating Windows Package File" + filename = getFilename('Wagic-windows') + '.zip' + createWindowsZipFile( filename ) + print >> sys.stderr, 'Created Resource Package for Standard Distribution: {0}'.format( filename) + +class ZipUtilities: + + def toZip(self, file, filename): + zip_file = zipfile.ZipFile(filename, 'w') + if os.path.isfile(file): + zip_file.write(file) + else: + self.addFolderToZip(zip_file, file) + zip_file.close() + + def addFolderToZip(self, zip_file, folder): + zip_file.writestr(folder + '/', '') + for file in os.listdir(folder): + if file != '.svn': + full_path = os.path.join(folder, file) + if os.path.isfile(full_path): + print 'File added: ' + str(full_path) + zip_file.write(full_path) + elif os.path.isdir(full_path): + print 'Entering folder: ' + str(full_path) + self.addFolderToZip(zip_file, full_path) + + +def main(): +## using optparse instead of argParse for now since python 2.7 may not be installed. + + parser = OptionParser() + parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform") + + (options, args) = parser.parse_args() + + if (options.platform): + if (options.platform == "ios"): + createIosResFile() + else: + createStandardResFile() + else: + createStandardResFile() + +if __name__ == "__main__": + main() From f82d89b3dbaa1bd5b5634fe57243b7a7f9697ac8 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 23 Aug 2014 00:47:30 +0200 Subject: [PATCH 02/14] Removed empty environment section --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7413b4ad6..fc230992b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,6 @@ #---------------------------------# # environment variables -environment: # environment: # global: # connection_string: server=12;password=13; From ec4be4f6b1497f33d8b23eda1253b2268c953c5d Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 23 Aug 2014 00:53:33 +0200 Subject: [PATCH 03/14] Uses real python path --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fc230992b..8d6b3d34a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,8 @@ # scripts that run after cloning repository install: - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py') - - "%PYTHON%/python.exe C:/get-pip.py" - - "%PYTHON%/Scripts/pip.exe install pyjavaproperties" + - "C:/Python27/python.exe C:/get-pip.py" + - "C:/Python27/Scripts/pip.exe install pyjavaproperties" #---------------------------------# # build configuration # @@ -63,7 +63,7 @@ artifacts: # scripts to run before deployment before_deploy: - cd projects/mtg/bin -- "%PYTHON%/python.exe createWindowsZip.py" +- "C:/Python27/python.exe createWindowsZip.py" # scripts to run after deployment after_deploy: From ce41791fa41dc127b5e33064e5d6ce799936421e Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Sat, 23 Aug 2014 09:36:46 +0200 Subject: [PATCH 04/14] Remove broken comments --- appveyor.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8d6b3d34a..f0372efcc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -74,14 +74,3 @@ deploy_script: # to disable deployment #deploy: off -#---------------------------------# -# global handlers # -#---------------------------------# - -# on successful build -on_success: - - do something - -# on build failure -on_failure: - - do something From 0127f7aab9cba11d610288a976af31d43a88e2b3 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 16:07:26 +0200 Subject: [PATCH 05/14] Tries to activate automatic artifact deployment to github release from appveyor --- appveyor.yml | 11 ++++-- projects/mtg/bin/createWindowsZip.py | 12 ++----- upload-binaries.py | 50 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 upload-binaries.py diff --git a/appveyor.yml b/appveyor.yml index f0372efcc..a51b3d52c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,11 +23,16 @@ # password: # secure: $#(JFDA)jQ@#$ +environment: + GH_TOKEN: + secure: dYnBDQkiY5oVjIlswzBX9BJigNtBGXgGlp1tK3XbHzrDEDrs2vaKD5m+Oz5OSz1C + # scripts that run after cloning repository install: - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py') - "C:/Python27/python.exe C:/get-pip.py" - "C:/Python27/Scripts/pip.exe install pyjavaproperties" + - "C:/Python27/Scripts/pip.exe install github3.py" #---------------------------------# # build configuration # @@ -62,14 +67,16 @@ artifacts: # scripts to run before deployment before_deploy: -- cd projects/mtg/bin -- "C:/Python27/python.exe createWindowsZip.py" + - cd projects/mtg/bin + - "C:/Python27/python.exe createWindowsZip.py" + - cd ../../.. # scripts to run after deployment after_deploy: # to run your custom scripts instead of provider deployments deploy_script: + - "C:/Python27/python.exe uploadBinary.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects\mtg\bin\Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" # to disable deployment #deploy: off diff --git a/projects/mtg/bin/createWindowsZip.py b/projects/mtg/bin/createWindowsZip.py index f550bdaf5..f89c885a7 100644 --- a/projects/mtg/bin/createWindowsZip.py +++ b/projects/mtg/bin/createWindowsZip.py @@ -30,11 +30,9 @@ def createStandardResFile(): cmd = 'python createResourceZip.py -n ' + getFilename('core') + '.zip' os.chdir("Res") os.system(cmd) -# os.system("python createResourceZip.py -n resources.zip") os.chdir("..") print "Creating Windows Package File" - filename = getFilename('Wagic-windows') + '.zip' - createWindowsZipFile( filename ) + createWindowsZipFile( 'Wagic-windows.zip' ) print >> sys.stderr, 'Created Resource Package for Standard Distribution: {0}'.format( filename) class ZipUtilities: @@ -68,13 +66,7 @@ def main(): (options, args) = parser.parse_args() - if (options.platform): - if (options.platform == "ios"): - createIosResFile() - else: - createStandardResFile() - else: - createStandardResFile() + createStandardResFile() if __name__ == "__main__": main() diff --git a/upload-binaries.py b/upload-binaries.py new file mode 100644 index 000000000..7434edc06 --- /dev/null +++ b/upload-binaries.py @@ -0,0 +1,50 @@ +import sys +import os +import zipfile +from pyjavaproperties import Properties +from optparse import OptionParser +from github3 import login + + +def suffixFilename(filename, build): + p = Properties(); + p.load(open('projects/mtg/build.number.properties')); + minor = p['build.minor']; + major = p['build.major']; + point = p['build.point']; + name, extension = os.path.splitext(filename) + filename = name + '-' + major + minor + point + '-' + build + extension + return filename + +def main(): + parser = OptionParser() + parser.add_option("-t", "--token", help="TOKEN: specify authentication token to use", metavar="TOKEN", dest="token") + parser.add_option("-s", "--sha", help="SHA: specify commit SHA", metavar="SHA", dest="sha") + parser.add_option("-l", "--local", help="FILE: specify local file path to upload", metavar="LOCAL", dest="local") + parser.add_option("-r", "--remote", help="NAME: specify remote asset name in the release.", metavar="REMOTE", dest="remote") + parser.add_option("-b", "--branch", help="BRANCH: specify branch of the commit", metavar="BRANCH", dest="branch") + + (options, args) = parser.parse_args() + + if (options.token and options.sha and options.local and options.remote and (options.branch == 'master' or options.branch == 'appveyor')): + gh = login(token = options.token) + else: + parser.print_help() + return + + repository = gh.repository('WagicProject', 'wagic') + # find reference + ref = gh.ref('tags/latest-master') + if(ref) + ref.update(options.sha) + + for r in repository.iter_releases(): + if r.name == 'latest-master' : +# filename = suffixFilename(options.remote, options.build) + filename = options.remote + with open(options.local, 'rb') as fd: + r.upload_asset('application/zip', filename , fd) + + +if __name__ == "__main__": + main() From db2b2fa3b5e6820fb0e2e8973f104522ae4eda79 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 17:07:00 +0200 Subject: [PATCH 06/14] Replaced \ by / --- appveyor.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a51b3d52c..317c109f2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,21 +8,6 @@ # environment configuration # #---------------------------------# -# environment variables -# environment: -# global: -# connection_string: server=12;password=13; -# service_url: https://127.0.0.1:8090 -# -# matrix: -# - db: mysql -# provider: mysql -# -# - db: mssql -# provider: mssql -# password: -# secure: $#(JFDA)jQ@#$ - environment: GH_TOKEN: secure: dYnBDQkiY5oVjIlswzBX9BJigNtBGXgGlp1tK3XbHzrDEDrs2vaKD5m+Oz5OSz1C @@ -76,7 +61,7 @@ after_deploy: # to run your custom scripts instead of provider deployments deploy_script: - - "C:/Python27/python.exe uploadBinary.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects\mtg\bin\Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" + - "C:/Python27/python.exe uploadBinaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" # to disable deployment #deploy: off From 2c2744f6fb3c38a5053be78e998e6233d6ad4035 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 17:40:05 +0200 Subject: [PATCH 07/14] Fixed python issue --- projects/mtg/bin/createWindowsZip.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/mtg/bin/createWindowsZip.py b/projects/mtg/bin/createWindowsZip.py index f89c885a7..8b2e7e4d9 100644 --- a/projects/mtg/bin/createWindowsZip.py +++ b/projects/mtg/bin/createWindowsZip.py @@ -32,8 +32,9 @@ def createStandardResFile(): os.system(cmd) os.chdir("..") print "Creating Windows Package File" - createWindowsZipFile( 'Wagic-windows.zip' ) - print >> sys.stderr, 'Created Resource Package for Standard Distribution: {0}'.format( filename) + filename = 'Wagic-windows.zip' + createWindowsZipFile( filename ) + print >> sys.stderr, 'Created Windows Package: {0}'.format( filename) class ZipUtilities: From b37afadb0126052214c8122c89e34894f6aa182f Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 17:59:04 +0200 Subject: [PATCH 08/14] Fixed typo. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 317c109f2..a60159108 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,7 +61,7 @@ after_deploy: # to run your custom scripts instead of provider deployments deploy_script: - - "C:/Python27/python.exe uploadBinaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" + - "C:/Python27/python.exe upload-binaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" # to disable deployment #deploy: off From 4e727bc1647f3821c2777660c5af24c6350cdff1 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 18:23:08 +0200 Subject: [PATCH 09/14] Fixed python typo --- upload-binaries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload-binaries.py b/upload-binaries.py index 7434edc06..0ddb5109a 100644 --- a/upload-binaries.py +++ b/upload-binaries.py @@ -35,7 +35,7 @@ def main(): repository = gh.repository('WagicProject', 'wagic') # find reference ref = gh.ref('tags/latest-master') - if(ref) + if(ref): ref.update(options.sha) for r in repository.iter_releases(): From c888e143a14cb8597f6ee59dbeeadc7d9c32b0e9 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 18:46:42 +0200 Subject: [PATCH 10/14] Fixed python typo --- upload-binaries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload-binaries.py b/upload-binaries.py index 0ddb5109a..a40ff0cd3 100644 --- a/upload-binaries.py +++ b/upload-binaries.py @@ -34,7 +34,7 @@ def main(): repository = gh.repository('WagicProject', 'wagic') # find reference - ref = gh.ref('tags/latest-master') + ref = repository.ref('tags/latest-master') if(ref): ref.update(options.sha) From 90b08db038c9b99e19a6411515e747570970b13b Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 24 Aug 2014 19:45:18 +0200 Subject: [PATCH 11/14] Updated travis to use python uploading script --- .travis.yml | 11 +++++++++-- appveyor.yml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3e70fef7..891c0a654 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: cpp branches: except: - latest-master + before_install: - export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk" - export PSPSDK="$PSPDEV/psp/sdk" @@ -15,6 +16,7 @@ before_install: - wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download - wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv - wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz -nv + install: - tar -x --xz -f sdk.lzma - tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2 @@ -22,10 +24,15 @@ install: - $ANDROID list sdk --extended -a - echo yes | $ANDROID update sdk --filter tools,platform-tools,build-tools-20.0.0,android-10 --no-ui --force --no-https - sudo pip install pyjavaproperties -script: ./travis-script.sh +- sudo pip install github3.py + env: global: secure: "fJgWlCFbde96OSQNGKUmowGX+ERPeqP+n1EOMf1+FJzOU4DdkTLRAlV5+5qnEX9jB/3mWN6iPpmG1qEz/SdDG3KHxJYs4ZU/Lu485O24zZ/+GdYBNsrvhPD9ckPGEMLDa1foEVTDnW0Dlkz3BCFcszjhtXGUJv7v6Pj6LRk1Mg8=" script: "./travis-script.sh" -after_success: ./upload-binaries.sh + +after_success: +- python upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l core.zip -r Wagic-core.zip -b $TRAVIS_BRANCH +- python upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/Android/bin/Wagic-debug.apk -r Wagic-android.apk -b $TRAVIS_BRANCH +- python upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/psprelease.zip -r Wagic-psp.zip -b $TRAVIS_BRANCH diff --git a/appveyor.yml b/appveyor.yml index a60159108..a0802bbc0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,7 +61,7 @@ after_deploy: # to run your custom scripts instead of provider deployments deploy_script: - - "C:/Python27/python.exe upload-binaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows -b %APPVEYOR_REPO_BRANCH%" + - "C:/Python27/python.exe upload-binaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows.zip -b %APPVEYOR_REPO_BRANCH%" # to disable deployment #deploy: off From 83e08695480ab3aee05ec06273b00d01ccf95e5e Mon Sep 17 00:00:00 2001 From: xawotihs Date: Mon, 25 Aug 2014 00:02:46 +0200 Subject: [PATCH 12/14] Updated python upload code to re-create new release 'latest-master' for each master commit --- upload-binaries.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/upload-binaries.py b/upload-binaries.py index a40ff0cd3..a580e907e 100644 --- a/upload-binaries.py +++ b/upload-binaries.py @@ -5,6 +5,28 @@ from pyjavaproperties import Properties from optparse import OptionParser from github3 import login +def checkRelease(repository, remote) + for r in repository.iter_releases(): + if r.name == 'latest-master' : + release = r + for a in r.assets : + if a.name == remote : + # need to delete the old release + r.delete() + # need also to delete the tag (reference) + ref = repository.ref('tags/latest-master') + ref.delete() + release = None + + if release is None: + # now, we recreate a new one + release = r.create_release('latest-master', 'master', 'latest-master', + 'Latest successful builds of the master branch automatically uploaded by Travis or AppVeyor CI.', + False, + True) + + return release + def suffixFilename(filename, build): p = Properties(); @@ -26,24 +48,17 @@ def main(): (options, args) = parser.parse_args() - if (options.token and options.sha and options.local and options.remote and (options.branch == 'master' or options.branch == 'appveyor')): + if (options.token and options.sha and options.local and options.remote and options.branch == 'master'): gh = login(token = options.token) else: parser.print_help() return repository = gh.repository('WagicProject', 'wagic') - # find reference - ref = repository.ref('tags/latest-master') - if(ref): - ref.update(options.sha) - - for r in repository.iter_releases(): - if r.name == 'latest-master' : -# filename = suffixFilename(options.remote, options.build) - filename = options.remote - with open(options.local, 'rb') as fd: - r.upload_asset('application/zip', filename , fd) + r = checkRelease(repository, options.remote) + filename = options.remote + with open(options.local, 'rb') as fd: + r.upload_asset('application/zip', filename , fd) if __name__ == "__main__": From 870f6e3b5885efbc6582717c1d8e13e6152d1db0 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Mon, 25 Aug 2014 00:27:40 +0200 Subject: [PATCH 13/14] Fixed python typo --- upload-binaries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload-binaries.py b/upload-binaries.py index a580e907e..9a8a1a4e3 100644 --- a/upload-binaries.py +++ b/upload-binaries.py @@ -5,7 +5,7 @@ from pyjavaproperties import Properties from optparse import OptionParser from github3 import login -def checkRelease(repository, remote) +def checkRelease(repository, remote): for r in repository.iter_releases(): if r.name == 'latest-master' : release = r From 3ba4aca8bc1df9ae8b74097d902827b215545cf1 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Mon, 25 Aug 2014 22:16:12 +0200 Subject: [PATCH 14/14] Fixed stupid bug in python release creation --- upload-binaries.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/upload-binaries.py b/upload-binaries.py index 9a8a1a4e3..01508f6d5 100644 --- a/upload-binaries.py +++ b/upload-binaries.py @@ -6,6 +6,7 @@ from optparse import OptionParser from github3 import login def checkRelease(repository, remote): + release = None for r in repository.iter_releases(): if r.name == 'latest-master' : release = r @@ -20,7 +21,7 @@ def checkRelease(repository, remote): if release is None: # now, we recreate a new one - release = r.create_release('latest-master', 'master', 'latest-master', + release = repository.create_release('latest-master', 'master', 'latest-master', 'Latest successful builds of the master branch automatically uploaded by Travis or AppVeyor CI.', False, True)