Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/build_config/updateReleaseInfo.py
169674 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
4
# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file updateReleaseInfo.py
16
# @author Michael Behrisch
17
# @date 2022-07-11
18
19
from __future__ import absolute_import
20
from __future__ import print_function
21
import os
22
import sys
23
import fileinput
24
import datetime
25
26
import version
27
28
SUMO_HOME = os.environ.get("SUMO_HOME", os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
29
30
last_release = version.get_version()
31
if "+" in last_release:
32
last_release = last_release[:last_release.index("+")]
33
dot_release = last_release.replace("_", ".")[1:]
34
35
version = sys.argv[1]
36
next_release = version.replace(".", "_")
37
if len(sys.argv) > 2:
38
date = datetime.datetime.strptime(sys.argv[2], "%Y-%m-%d")
39
else:
40
date = datetime.datetime.now() + datetime.timedelta(days=1)
41
print("updating", dot_release, "to", version, "release date", date)
42
author_names = []
43
with open(os.path.join(SUMO_HOME, "AUTHORS")) as authors:
44
header_seen = False
45
for line in authors:
46
line = line.strip()
47
if line == "" and not header_seen:
48
header_seen = True
49
if not header_seen or " " not in line or line[0] == "@":
50
continue
51
if "<" in line:
52
name = line[:line.index("<") - 1]
53
elif "*" in line:
54
name = line[:line.index("*") - 1]
55
else:
56
name = line
57
if " " in name:
58
author_names.append(' - name: "%s"\n' % name)
59
60
with fileinput.FileInput(os.path.join(SUMO_HOME, "CITATION.cff"), inplace=True) as cff:
61
have_authors = False
62
for line in cff:
63
if line[:14] == "date-released:":
64
line = date.strftime('date-released: "%Y-%m-%d"\n')
65
if line[:8] == "version:":
66
line = 'version: %s\n' % version
67
if 'sumo/releases/tag/v' in line:
68
line = line[:line.find('sumo/releases/tag/v') + 19] + next_release + '"\n'
69
if 'sumo.dlr.de/releases/' in line:
70
line = line[:line.find('sumo.dlr.de/releases/') + 21] + version + '/"\n'
71
if line[:8] == "message:":
72
last = None
73
for a in sorted(author_names):
74
if a != last:
75
print(a, end='')
76
last = a
77
have_authors = False
78
if line == "authors:\n" and not have_authors:
79
have_authors = True
80
print(line, end='')
81
elif have_authors:
82
author_names.append(line)
83
else:
84
print(line, end='')
85
86
with fileinput.FileInput(os.path.join(SUMO_HOME, "src", "config.h.cmake"), inplace=True) as config:
87
for line in config:
88
if line == "#define HAVE_VERSION_H\n":
89
print("//" + line, end='')
90
else:
91
print(line.replace(dot_release, version), end='')
92
93
with fileinput.FileInput(os.path.join(SUMO_HOME, "CMakeLists.txt"), inplace=True) as cmake:
94
for line in cmake:
95
if line == 'set(PACKAGE_VERSION "git")\n':
96
print(line.replace("git", version), end='')
97
else:
98
print(line, end='')
99
100
with fileinput.FileInput(os.path.join(SUMO_HOME, "docs", "web", "mkdocs.yml"), inplace=True) as mkdocs:
101
for line in mkdocs:
102
if "ReleaseDate:" in line:
103
print(' ReleaseDate:', date.strftime("%d.%m.%Y"))
104
else:
105
print(line.replace(dot_release, version), end='')
106
107
with fileinput.FileInput(os.path.join(SUMO_HOME, "docs", "web", "docs", "ChangeLog.md"), inplace=True) as mkdocs:
108
for line in mkdocs:
109
if "## Git Main" in line:
110
print(line.replace("Git Main", date.strftime("Version " + version + " (%d.%m.%Y)")), end='')
111
else:
112
print(line, end='')
113
114
with fileinput.FileInput(os.path.join(SUMO_HOME, "build_config", "package", "sumo.metainfo.xml"),
115
inplace=True) as metainfo:
116
have_next = False
117
for line in metainfo:
118
if next_release in line:
119
have_next = True
120
if not have_next and last_release in line:
121
print(' <release version="v%s" date="%s"/>' % (next_release, date.strftime("%Y-%m-%d")))
122
print(line, end='')
123
124