Skip to content

Commit

Permalink
contrib: learn to build website/_uploads
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
  • Loading branch information
nicolas33 committed Apr 9, 2018
1 parent dd0be5e commit 57b2794
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down Expand Up @@ -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)
26 changes: 20 additions & 6 deletions contrib/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)


__VERSION__ = "0.1"
__VERSION__ = "0.2"

SPHINXBUILD = 'sphinx-build'
DOCSDIR = 'docs'
Expand Down Expand Up @@ -260,6 +260,15 @@ def close(self):


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:
Expand Down Expand Up @@ -292,9 +301,7 @@ def buildLatest(self, version):
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
Expand All @@ -303,6 +310,9 @@ def exportDocs(self, version):
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()
Expand Down Expand Up @@ -410,8 +420,12 @@ def updateWebsite(self, newVersion):
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
Expand Down
34 changes: 34 additions & 0 deletions docs/build-uploads.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 57b2794

Please sign in to comment.