Commit 1f727f6a authored by Eric Engestrom's avatar Eric Engestrom

add script to post releases to the website

Signed-off-by: Eric Engestrom's avatarEric Engestrom <>
Reviewed-by: Erik Faye-Lund 's avatarErik Faye-Lund <>
parent 9bfbc799
Pipeline #166938 passed with stages
in 16 seconds
#!/usr/bin/env python3
import argparse
import datetime
from distutils.version import StrictVersion
import fileinput
import pathlib
import subprocess
def update_version(version: str) -> None:
p = pathlib.Path('config.yml')
with fileinput.input(p, inplace=True) as f:
def replace_version(line: str) -> str:
if 'LatestVersion:' in line:
# Avoid overwriting 20.1.0 when releasing 20.0.8
old_version = line.split(':')[1].strip()
if StrictVersion(old_version) < StrictVersion(version):
return f' LatestVersion: {version}\n'
return line
for line in f:
print(replace_version(line).rstrip())['git', 'add', p])
def post_news(version: str) -> None:
version_slug = version.replace('.', '-')
p = pathlib.Path(f'content/news/releases/mesa-{version_slug}')
now =
with open(p, 'w') as f:
f.write(f'title: "Mesa {version} is released"\n')
f.write(f'date: {now.strftime("%Y-%m-%d %H:%M:%S")}\n')
f.write('category: releases\n')
f.write('tags: []\n')
f.write(f'[Mesa {version}]({version}.html) is released. ')
if version.endswith('.0'):
f.write('This is a new development release. ')
f.write('See the release notes for more information about this release.')
f.write('This is a bug fix release.')
f.write('\n')['git', 'add', p])
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('version', help='The released version.')
args = parser.parse_args()
# Don't post release candidates to the homepage
if 'rc' in args.version:
post_news(args.version)['git', 'commit', '-m',
f'release {args.version}'])
if __name__ == '__main__':
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment