mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-28 16:11:28 +00:00
Update release script
This commit is contained in:
parent
ec80a1ab51
commit
fac207816c
@ -123,19 +123,21 @@ class Runner:
|
|||||||
self.cwd = '.'
|
self.cwd = '.'
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
check_call(args, cwd=self.cwd, **kwargs)
|
kwargs['cwd'] = kwargs.get('cwd', self.cwd)
|
||||||
|
check_call(args, **kwargs)
|
||||||
|
|
||||||
workdir = tempfile.mkdtemp()
|
workdir = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
run = Runner()
|
run = Runner()
|
||||||
run('git', 'clone', 'git@github.com:cppformat/cppformat.git', workdir)
|
cppformat_dir = os.path.join(workdir, 'cppformat')
|
||||||
|
run('git', 'clone', 'git@github.com:cppformat/cppformat.git', cppformat_dir)
|
||||||
|
|
||||||
# Convert changelog from RST to GitHub-flavored Markdown and get the version.
|
# Convert changelog from RST to GitHub-flavored Markdown and get the version.
|
||||||
changelog = 'ChangeLog.rst'
|
changelog = 'ChangeLog.rst'
|
||||||
changelog_path = os.path.join(workdir, changelog)
|
changelog_path = os.path.join(cppformat_dir, changelog)
|
||||||
changes, version = core.publish_file(source_path=changelog_path, writer=MDWriter())
|
changes, version = core.publish_file(source_path=changelog_path, writer=MDWriter())
|
||||||
cmakelists = 'CMakeLists.txt'
|
cmakelists = 'CMakeLists.txt'
|
||||||
for line in fileinput.input(os.path.join(workdir, cmakelists), inplace=True):
|
for line in fileinput.input(os.path.join(cppformat_dir, cmakelists), inplace=True):
|
||||||
prefix = 'set(CPPFORMAT_VERSION '
|
prefix = 'set(CPPFORMAT_VERSION '
|
||||||
if line.startswith(prefix):
|
if line.startswith(prefix):
|
||||||
line = prefix + version + ')\n'
|
line = prefix + version + ')\n'
|
||||||
@ -152,7 +154,7 @@ try:
|
|||||||
line = '-' * title_len + '\n'
|
line = '-' * title_len + '\n'
|
||||||
title_len = 0
|
title_len = 0
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
run.cwd = workdir
|
run.cwd = cppformat_dir
|
||||||
run('git', 'checkout', '-b', 'release')
|
run('git', 'checkout', '-b', 'release')
|
||||||
run('git', 'add', changelog, cmakelists)
|
run('git', 'add', changelog, cmakelists)
|
||||||
run('git', 'commit', '-m', 'Update version')
|
run('git', 'commit', '-m', 'Update version')
|
||||||
@ -160,16 +162,22 @@ try:
|
|||||||
# Build the docs and package.
|
# Build the docs and package.
|
||||||
run('cmake', '.')
|
run('cmake', '.')
|
||||||
run('make', 'doc', 'package_source')
|
run('make', 'doc', 'package_source')
|
||||||
|
site_dir = os.path.join(workdir, 'cppformat.github.io')
|
||||||
|
run('git', 'clone', 'git@github.com:cppformat/cppformat.github.io.git', site_dir)
|
||||||
|
doc_dir = os.path.join(site_dir, version)
|
||||||
|
shutil.copytree(os.path.join(cppformat_dir, 'doc', 'html'), doc_dir,
|
||||||
|
ignore=shutil.ignore_patterns('.doctrees', '.buildinfo'))
|
||||||
|
run.cwd = site_dir
|
||||||
|
run('git', 'add', doc_dir)
|
||||||
|
run('git', 'commit', '-m', 'Update docs')
|
||||||
|
|
||||||
# Create a release on GitHub.
|
# Create a release on GitHub.
|
||||||
run('git', 'push', 'origin', 'release')
|
run('git', 'push', 'origin', 'release', cwd=cppformat_dir)
|
||||||
r = requests.post('https://api.github.com/repos/cppformat/cppformat/releases',
|
r = requests.post('https://api.github.com/repos/cppformat/cppformat/releases',
|
||||||
params={'access_token': os.getenv('CPPFORMAT_TOKEN')},
|
params={'access_token': os.getenv('CPPFORMAT_TOKEN')},
|
||||||
data=json.dumps({'tag_name': version, 'target_commitish': 'release',
|
data=json.dumps({'tag_name1': version, 'target_commitish': 'release',
|
||||||
'body': changes, 'draft': True}))
|
'body': changes, 'draft': True}))
|
||||||
if r.status_code != 201:
|
if r.status_code != 201:
|
||||||
raise Exception('Failed to create a release ' + str(r))
|
raise Exception('Failed to create a release ' + str(r))
|
||||||
|
|
||||||
# TODO: update website
|
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(workdir)
|
shutil.rmtree(workdir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user