Commit 534b8bad authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the file VERSION. Modify build_version.py, get_versions.

parent f2dd7f16
0.8.1
\ No newline at end of file
......@@ -11,8 +11,8 @@
The version identifier should contains alphanumeric characters
including ".", "-" and "_".
Push version identifier in the javascript library.
Push version number in the CHANGELOG.
Push release identifier in the javascript library, CHANGELOG and
VERSION files.
Build debug and minified version of the javascript library.
Build the web2py plugin files.
Build the documentations.
......@@ -24,7 +24,7 @@
AUTHOR
R. Le Gac, renaud.legac@free.fr
Copyright (c) 2012-2015 R. Le Gac
Copyright (c) 2012-2016 R. Le Gac
"""
import argparse
......@@ -38,7 +38,7 @@ import urllib
from os.path import join as opj
from subprocess import call
from subprocess import call, check_output
from numexpr.version import release
# constants
......@@ -63,6 +63,7 @@ PDFDOC = opj(DOCS, PDF)
PLUGIN_W2P = 'web2py.plugin.%s.%s.w2p'
REFERENCE = 'reference'
USER = 'user'
VERSION = "VERSION"
W2P = "web2py.plugin.%s.%s.min.w2p"
# basic commands
......@@ -196,7 +197,8 @@ def build_plugin(plugin_name, release, files):
"""Helper function to build a web2py plugin.
It is inspired by the function: ``web2py/gluon/fileutils/w2p_pack_plugin``.
The binary file is moved to the ``plugin_dbui_build`` directory if it exists.
The binary file is moved to the ``plugin_dbui_build`` directory
if it exists.
Args:
plugin_name (str): the name of the plugin, *e.g.* extjs
......@@ -458,9 +460,8 @@ def get_version():
"""Get the current version identifier.
"""
txt = open(JSBASE, 'rb').read()
match = re.match(r"(.+ version: ')([\w._-]*)('.+)", txt, re.DOTALL)
return match.group(2)
with open(VERSION, "rb") as fi:
return fi.read()
def git(*args, **kwargs):
......@@ -530,9 +531,9 @@ def jsduck():
call(cmd)
# run JsDuck
cmd = ["jsduck", EXTJSSRC, JSLIBSRC, \
"--output", JSDOC, \
"--title", "plugin_dbui %s" % get_version(), \
cmd = ["jsduck", EXTJSSRC, JSLIBSRC,
"--output", JSDOC,
"--title", "plugin_dbui %s" % get_version(),
"--warnings=-all:" + EXTJSSRC]
call(cmd)
......@@ -550,16 +551,13 @@ def set_version(version):
print "Update CHANGELOG and App.js files with the release", version, "..."
# check tag in git
fi = tempfile.TemporaryFile()
git("tag", stdout=fi)
fi.seek(0)
if version in fi.read():
if version in check_output(["git", "tag"]).split("\n"):
print "\n\tRelease %s already exit in git" % version
sys.exit(1)
print 'Set release', version, 'in', JSBASE
txt = open(JSBASE, 'rb').read()
with open(JSBASE) as fi:
txt = fi.read()
# look for a pattern App.version = '0.8.3'; in appbase.js
# split the the string in 3 parts (pre, version, post)
......@@ -567,25 +565,25 @@ def set_version(version):
if match.group(2) == version:
msg = '\n\tVersion "%s" already exists in the appbase.js file !'
print msg % version
print msg % version
rep = raw_input('\tDo you want to continue [n]?')
if rep not in ('y', 'yes'):
sys.exit(1)
# update the version and write a new file
txt = match.group(1) + version + match.group(3)
fi = open(JSBASE, 'wb')
fi.write(txt)
fi.close()
with open(JSBASE, 'w') as fi:
fi.write(txt)
# look for a pattern HEAD in the CHANGELOG
# split the the string in 2 parts (pre HEAD, post HEAD)
print 'Set release', version, 'in', CHANGELOG
txt = open(CHANGELOG, 'rb').read()
with open(CHANGELOG) as fi:
txt = fi.read()
match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL)
if match == None:
if match is None:
print '\n\tNo HEAD tag in the CHANGELOG!\n'
rep = raw_input('\tDo you want to continue [n]?')
if rep not in ('y', 'yes'):
......@@ -594,11 +592,17 @@ def set_version(version):
# update the version and edit the CHANGELOG
tpl = (match.group(1), version, NOW.strftime('%b %Y'), match.group(2))
txt = '%s\n%s (%s)\n%s' % tpl
fi = open(CHANGELOG, 'wb')
fi.write(txt)
fi.close()
with open(CHANGELOG, 'w') as fi:
fi.write(txt)
call(["vim", CHANGELOG])
# update VERSION
print 'Set release', version, 'in', VERSION
with open(VERSION, 'w') as fi:
fi.write(version)
# cleaning
fn = "%s~" % CHANGELOG
if os.path.exists(fn):
......
......@@ -4,7 +4,6 @@
import os
import re
import subprocess
import tempfile
from constant import INLINE_ALERT
......@@ -22,8 +21,9 @@ from gluon.validators import (IS_DATE_IN_RANGE,
IS_MATCH,
IS_LENGTH)
GIT = '/usr/bin/git'
STOREID = '%sStore'
GIT = "/usr/bin/git"
STOREID = "%sStore"
VERSION = "VERSION"
def as_list(val):
......@@ -654,15 +654,16 @@ def get_versions():
# version of the application
myapp = current.T("unknown")
if os.path.exists(GIT):
if os.path.exists(VERSION):
with open(os.path.join(server_path, VERSION)) as fi:
myapp = fi.read()
elif os.path.exists(GIT):
ref_path = os.getcwd()
os.chdir(server_path)
fi = tempfile.TemporaryFile()
subprocess.call(["git", "describe", "--tags"], stdout=fi)
fi.seek(0)
myapp = fi.read().strip('\n')
fi.close()
myapp = subprocess.check_output(["git", "describe", "--tags"])
myapp = myapp.strip('\n')
os.chdir(ref_path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment