From 57b2794bfb68983a10d9d1af152eedffc735c1e2 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Mon, 9 Apr 2018 01:37:40 +0200 Subject: [PATCH] contrib: learn to build website/_uploads Signed-off-by: Nicolas Sebrecht --- Makefile | 5 +++-- contrib/release.py | 26 ++++++++++++++++++++------ docs/build-uploads.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 docs/build-uploads.sh diff --git a/Makefile b/Makefile index 57c5be2..6b71da2 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Warning: VERSION, ABBREV and TARGZ are used in docs/build-uploads.sh. VERSION=$(shell ./offlineimap.py --version) ABBREV=$(shell git log --format='%h' HEAD~1..) -TARGZ=offlineimap-$(VERSION)-$(ABBREV) +TARGZ=offlineimap-v$(VERSION)-$(ABBREV) SHELL=/bin/bash RST2HTML=`type rst2html >/dev/null 2>&1 && echo rst2html || echo rst2html.py` @@ -49,7 +50,7 @@ websitedoc: targz: ../$(TARGZ) ../$(TARGZ): - cd .. && tar -zhcv -f $(TARGZ).tar.gz --exclude '.*.swp' --exclude '.*.swo' --exclude '*.pyc' --exclude '__pycache__' offlineimap/{bin,Changelog.md,Changelog.maint.md,contrib,CONTRIBUTING.rst,COPYING,docs,MAINTAINERS.rst,Makefile,MANIFEST.in,offlineimap,offlineimap.conf,offlineimap.conf.minimal,offlineimap.py,README.md,requirements.txt,scripts,setup.cfg,setup.py,snapcraft.yaml,test,tests,TODO.rst} + cd .. && tar -zhcv --transform s,^offlineimap,$(TARGZ), -f $(TARGZ).tar.gz --exclude '.*.swp' --exclude '.*.swo' --exclude '*.pyc' --exclude '__pycache__' offlineimap/{bin,Changelog.md,Changelog.maint.md,contrib,CONTRIBUTING.rst,COPYING,docs,MAINTAINERS.rst,Makefile,MANIFEST.in,offlineimap,offlineimap.conf,offlineimap.conf.minimal,offlineimap.py,README.md,requirements.txt,scripts,setup.cfg,setup.py,snapcraft.yaml,test,tests,TODO.rst} rpm: targz cd .. && sudo rpmbuild -ta $(TARGZ) diff --git a/contrib/release.py b/contrib/release.py index d3d20cb..abbb59f 100755 --- a/contrib/release.py +++ b/contrib/release.py @@ -26,7 +26,7 @@ from helpers import ( ) -__VERSION__ = "0.1" +__VERSION__ = "0.2" SPHINXBUILD = 'sphinx-build' DOCSDIR = 'docs' @@ -260,6 +260,15 @@ Pip: class Website(object): + def updateUploads(self): + req = ("update uploads/ of the website? " + "(warning: checksums will change if they already exist)") + if User.yesNo(req, defaultToYes=True) is False: + return False + if check_call(shlex.split("./docs/build-uploads.sh")) != 0: + return exit(5) + return True + def updateAPI(self): req = "update API of the website? (requires {})".format(SPHINXBUILD) if User.yesNo(req, defaultToYes=True) is False: @@ -292,9 +301,7 @@ Then, commit and push changes of the website.""".format(SPHINXBUILD, DOCSDIR)) with open(WEBSITE_LATEST, 'w') as fd: fd.write(WEBSITE_LATEST_SKEL.format(stable=version)) - def exportDocs(self, version): - branchName = "import-v{}".format(version) - + def exportDocs(self): if not goTo(DOCSDIR): User.pause() return @@ -303,6 +310,9 @@ Then, commit and push changes of the website.""".format(SPHINXBUILD, DOCSDIR)) print("error while calling 'make websitedoc'") exit(3) + def createImportBranch(self, version): + branchName = "import-v{}".format(version) + Git.chdirToRepositoryTopLevel() if not goTo("website"): User.pause() @@ -410,8 +420,12 @@ class Release(object): self.state.saveWebsite() website = Website() website.buildLatest(newVersion) - if website.updateAPI(): - self.websiteBranch = website.exportDocs(newVersion) + res_upload = website.updateUploads() + res_api = website.updateAPI() + if res_api: + res_export = website.exportDocs() + if True in [res_upload, res_api, res_export]: + self.websiteBranch = website.createImportBranch(newVersion) def getWebsiteBranch(self): return self.websiteBranch diff --git a/docs/build-uploads.sh b/docs/build-uploads.sh new file mode 100755 index 0000000..3bef541 --- /dev/null +++ b/docs/build-uploads.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# vim: expandtab ts=2 : + +WEBSITE_UPLOADS='./website/_uploads' + +while true +do + test -d .git && break + cd .. +done + +set -e + +echo "make clean" +make clean >/dev/null +echo "make targz" +make targz >/dev/null + +# Defined in the root Makefile. +version="$(./offlineimap.py --version)" +abbrev="$(git log --format='%h' HEAD~1..)" +targz="../offlineimap-v${version}-${abbrev}.tar.gz" + +filename="offlineimap-v${version}.tar.gz" + +mv -v "$targz" "${WEBSITE_UPLOADS}/${filename}" +cd "$WEBSITE_UPLOADS" +for digest in sha1 sha256 sha512 +do + target="${filename}.${digest}" + echo "Adding digest ${WEBSITE_UPLOADS}/${target}" + "${digest}sum" "$filename" > "$target" +done