From 672c68153c99f6205b7b8ca2527324f50394b351 Mon Sep 17 00:00:00 2001 From: david-acm Date: Tue, 21 May 2019 18:55:50 -0600 Subject: [PATCH] add integration with appveyor to do automatic releasing. --- appveyor.yml | 30 ++++++++++++++++ buildVars.py | 2 +- sconstruct | 98 +++++++++++++++++++++++----------------------------- 3 files changed, 74 insertions(+), 56 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4607247 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,30 @@ +version: '{branch}-{build}' +environment: + PY_PYTHON: 3.7-32 +install: +- cmd: >- + set PATH=C:\Python37\Scripts;%PATH% + + pip install wheel + + pip install scons + + pip install markdown +build_script: +- cmd: scons +artifacts: +- path: '*.nvda-addon' + name: addon + type: WebDeployPackage +before_deploy: +- ps: $env:REPO_NAME = $env:APPVEYOR_REPO_NAME.Substring($env:APPVEYOR_REPO_NAME.IndexOf('/') + 1) +deploy: +- provider: GitHub + tag: $(APPVEYOR_REPO_TAG_NAME) + release: Release $(APPVEYOR_REPO_TAG_NAME) + description: This is the release $(APPVEYOR_REPO_TAG_NAME) of the $(REPO_NAME) addon for the NVDA screen reader built and uploaded to GitHub using Appveyor. + auth_token: + secure: hwgAZezYq6+gi0L3+FGMaWOT/GBGeyVH9QqPxGSqVVGi3+VzqjMFy/9PcAMSE5cL + artifact: addon + on: + appveyor_repo_tag: true \ No newline at end of file diff --git a/buildVars.py b/buildVars.py index 4130bc2..b7c4e47 100644 --- a/buildVars.py +++ b/buildVars.py @@ -19,7 +19,7 @@ # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description" : _("""This is the IBMTTS synthesizer driver for NVDA."""), # version - "addon_version" : "19.2b6", + "addon_version" : "19.5a1", # Author(s) "addon_author" : u"David CM and others", # URL for the add-on documentation support diff --git a/sconstruct b/sconstruct index 6943c26..d1e3c76 100644 --- a/sconstruct +++ b/sconstruct @@ -8,20 +8,29 @@ import gettext import os import os.path import zipfile -import six +import sys +sys.dont_write_bytecode = True + import buildVars + def md2html(source, dest): import markdown lang = os.path.basename(os.path.dirname(source)).replace('_', '-') - title="{addonSummary} {addonVersion}".format(addonSummary=buildVars.addon_info["addon_summary"], addonVersion=buildVars.addon_info["addon_version"]) + localeLang = os.path.basename(os.path.dirname(source)) + try: + _ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[localeLang]).ugettext if sys.version_info.major == 2 else gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[localeLang]).gettext + title=u"{0}".format(_(buildVars.addon_info["addon_summary"])) + except: + title="{0}".format(buildVars.addon_info["addon_summary"]) headerDic = { "[[!meta title=\"": "# ", "\"]]": " #", } with codecs.open(source, "r", "utf-8") as f: mdText = f.read() - for k, v in six.iteritems(headerDic): + headerList = headerDic.iteritems () if sys.version_info.major == 2 else list(headerDic.items()) + for k, v in headerList: mdText = mdText.replace(k, v, 1) htmlText = markdown.markdown(mdText) with codecs.open(dest, "w", "utf-8") as f: @@ -38,36 +47,13 @@ def md2html(source, dest): f.write(htmlText) f.write("\n\n") -def mdTool(env): - mdAction=env.Action( - lambda target,source,env: md2html(source[0].path, target[0].path), - lambda target,source,env: 'Generating %s'%target[0], - ) - mdBuilder=env.Builder( - action=mdAction, - suffix='.html', - src_suffix='.md', - ) - env['BUILDERS']['markdown']=mdBuilder - -vars = Variables() -vars.Add("version", "The version of this build", buildVars.addon_info["addon_version"]) -vars.Add(BoolVariable("dev", "Whether this is a daily development version", False)) -vars.Add("channel", "Update channel for this build", buildVars.addon_info["addon_updateChannel"]) - -env = Environment(variables=vars, ENV=os.environ, tools=['gettexttool', mdTool]) -env.Append(**buildVars.addon_info) +def generateHelpFiles (source, target, env, for_signature): + action = env.Action(lambda target, source, env : md2html(source[0].abspath, target[0].abspath) and None, + lambda target, source, env : "Generating %s" % target[0]) + return action -if env["dev"]: - import datetime - buildDate = datetime.datetime.now() - year, month, day = str(buildDate.year), str(buildDate.month), str(buildDate.day) - env["addon_version"] = "".join([year, month.zfill(2), day.zfill(2), "-dev"]) - env["channel"] = "dev" -elif env["version"] is not None: - env["addon_version"] = env["version"] -if "channel" in env and env["channel"] is not None: - env["addon_updateChannel"] = env["channel"] +env = Environment(ENV=os.environ, tools=['gettexttool']) +env.Append(**buildVars.addon_info) addonFile = env.File("${addon_name}-${addon_version}.nvda-addon") @@ -81,6 +67,7 @@ def manifestGenerator(target, source, env, for_signature): lambda target, source, env : "Generating manifest %s" % target[0]) return action + def translatedManifestGenerator(target, source, env, for_signature): dir = os.path.abspath(os.path.join(os.path.dirname(str(source[0])), "..")) lang = os.path.basename(dir) @@ -89,6 +76,9 @@ def translatedManifestGenerator(target, source, env, for_signature): return action env['BUILDERS']['NVDAAddon'] = Builder(generator=addonGenerator) +env['BUILDERS']['markdown']=Builder(generator = generateHelpFiles, + suffix='.html', + src_suffix='.md') env['BUILDERS']['NVDAManifest'] = Builder(generator=manifestGenerator) env['BUILDERS']['NVDATranslatedManifest'] = Builder(generator=translatedManifestGenerator) @@ -103,6 +93,8 @@ def createAddonHelp(dir): readmeTarget = env.Command(readmePath, "readme.md", Copy("$TARGET", "$SOURCE")) env.Depends(addon, readmeTarget) + + def createAddonBundleFromPath(path, dest): """ Creates a bundle from a directory that contains an addon manifest file.""" basedir = os.path.abspath(path) @@ -117,17 +109,14 @@ def createAddonBundleFromPath(path, dest): return dest def generateManifest(source, dest): - addon_info = buildVars.addon_info - addon_info["addon_version"] = env["addon_version"] - addon_info["addon_updateChannel"] = env["addon_updateChannel"] with codecs.open(source, "r", "utf-8") as f: manifest_template = f.read() - manifest = manifest_template.format(**addon_info) + manifest = manifest_template.format(**buildVars.addon_info) with codecs.open(dest, "w", "utf-8") as f: f.write(manifest) def generateTranslatedManifest(source, language, out): - _ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).gettext + _ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext if sys.version_info.major == 2 else gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).gettext vars = {} for var in ("addon_summary", "addon_description"): vars[var] = _(buildVars.addon_info[var]) @@ -142,28 +131,10 @@ def expandGlobs(files): addon = env.NVDAAddon(addonFile, env.Dir('addon')) -langDirs = [f for f in env.Glob(os.path.join("addon", "locale", "*"))] - -#Allow all NVDA's gettext po files to be compiled in source/locale, and manifest files to be generated -for dir in langDirs: - poFile = dir.File(os.path.join("LC_MESSAGES", "nvda.po")) - moFile=env.gettextMoFile(poFile) - env.Depends(moFile, poFile) - translatedManifest = env.NVDATranslatedManifest(dir.File("manifest.ini"), [moFile, os.path.join("manifest-translated.ini.tpl")]) - env.Depends(translatedManifest, ["buildVars.py"]) - env.Depends(addon, [translatedManifest, moFile]) - pythonFiles = expandGlobs(buildVars.pythonSources) for file in pythonFiles: env.Depends(addon, file) -#Convert markdown files to html -createAddonHelp("addon") # We need at least doc in English and should enable the Help button for the add-on in Add-ons Manager -for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')): - htmlFile = env.markdown(mdFile) - env.Depends(htmlFile, mdFile) - env.Depends(addon, htmlFile) - # Pot target i18nFiles = expandGlobs(buildVars.i18nSources) gettextvars={ @@ -185,4 +156,21 @@ manifest = env.NVDAManifest(os.path.join("addon", "manifest.ini"), os.path.join( env.Depends(manifest, "buildVars.py") env.Depends(addon, manifest) +createAddonHelp("addon") # We need at least doc in English and should enable the Help button for the add-on in Add-ons Manager +langDirs = [f for f in env.Glob(os.path.join("addon", "locale", "*"))] + +#Allow all NVDA's gettext po files to be compiled in source/locale, and manifest files to be generated +for dir in langDirs: + poFile = dir.File(os.path.join("LC_MESSAGES", "nvda.po")) + moFile=env.gettextMoFile(poFile) + env.Depends(moFile, poFile) + translatedManifest = env.NVDATranslatedManifest(dir.File("manifest.ini"), [moFile, os.path.join("manifest-translated.ini.tpl")]) + env.Depends(translatedManifest, ["buildVars.py"]) + env.Depends(addon, [translatedManifest, moFile]) + #Convert markdown files to html + for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')): + htmlFile = env.markdown(mdFile) + env.Depends(htmlFile, [mdFile, moFile]) + env.Depends(addon, htmlFile) env.Default(addon) +env.Clean (addon, ['.sconsign.dblite', 'addon/doc/en/'])