Skip to content

Commit

Permalink
Update the release script
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Dec 26, 2024
1 parent 0e8aad9 commit 3c8aad8
Showing 1 changed file with 7 additions and 46 deletions.
53 changes: 7 additions & 46 deletions support/manage.py → support/release.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env python3

"""Manage site and releases.
"""Make a release.
Usage:
manage.py release [<branch>]
manage.py site
release.py [<branch>]
For the release command $FMT_TOKEN should contain a GitHub personal access token
obtained from https://github.com/settings/tokens.
Expand All @@ -13,7 +12,6 @@
from __future__ import print_function
import datetime, docopt, errno, fileinput, json, os
import re, shutil, sys
from contextlib import contextmanager
from subprocess import check_call
import urllib.request

Expand Down Expand Up @@ -82,46 +80,15 @@ class Env:
return env


fmt_repo_url = '[email protected]:fmtlib/fmt'


def update_site(env):
env.fmt_repo.update(fmt_repo_url)

doc_repo = Git(os.path.join(env.build_dir, 'fmt.dev'))
doc_repo.update('[email protected]:fmtlib/fmt.dev')

version = '11.0.0'
clean_checkout(env.fmt_repo, version)
target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc')

# Build the docs.
html_dir = os.path.join(env.build_dir, 'html')
if os.path.exists(html_dir):
shutil.rmtree(html_dir)
include_dir = env.fmt_repo.dir
import build
build.build_docs(version, doc_dir=target_doc_dir,
include_dir=include_dir, work_dir=env.build_dir)
shutil.rmtree(os.path.join(html_dir, '.doctrees'))
# Copy docs to the website.
version_doc_dir = os.path.join(doc_repo.dir, version)
try:
shutil.rmtree(version_doc_dir)
except OSError as e:
if e.errno != errno.ENOENT:
raise
shutil.move(html_dir, version_doc_dir)


def release(args):
if __name__ == '__main__':
args = docopt.docopt(__doc__)
env = create_build_env()
fmt_repo = env.fmt_repo

branch = args.get('<branch>')
if branch is None:
branch = 'master'
if not fmt_repo.update('-b', branch, fmt_repo_url):
if not fmt_repo.update('-b', branch, '[email protected]:fmtlib/fmt'):
clean_checkout(fmt_repo, branch)

# Update the date in the changelog and extract the version and the first
Expand Down Expand Up @@ -217,11 +184,5 @@ def release(args):
raise Exception(f'Failed to upload an asset '
'{response.status} {response.reason}')

update_site(env)

if __name__ == '__main__':
args = docopt.docopt(__doc__)
if args.get('release'):
release(args)
elif args.get('site'):
update_site(create_build_env())
short_version = '.'.join(version.split('.')[:-1])
check_call(['./mkdocs', 'deploy', short_version])

0 comments on commit 3c8aad8

Please sign in to comment.