contrib: learn to build website/_uploads

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2018-04-09 01:37:40 +02:00
parent dd0be5e166
commit 57b2794bfb
3 changed files with 57 additions and 8 deletions

View File

@ -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)

View File

@ -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

34
docs/build-uploads.sh Executable file
View File

@ -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