Debian Codegraph @

tasks/build_/_release.py

raw symbols SCIP
1 # -*- coding: ascii -*-
2 #
3 # Copyright 2007 - 2025
4 # Andr\xe9 Malo or his licensors, as applicable
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 """
18 Release code
19 ~~~~~~~~~~~~
20
21 """
22
23 import re as _re
24
25
26 def check_committed(ctx):
27 """Check if everything is committed"""
28 git = ctx.shell.frompath("git")
29 lines = ctx.run(
30 ctx.c("%s branch --color=never", git), env=dict(LC_ALL="C"), hide=True
31 ).stdout.splitlines()
32 for line in lines:
33 if line.startswith("*"):
34 branch = line.split(None, 1)[1]
35 break
36 else:
37 ctx.fail("Could not determine current branch.")
38
39 if branch != "master":
40 rex = _re.compile(r"^\d+(?:\.\d+)*\.[xX]$").match
41 match = rex(branch)
42 if not match:
43 ctx.fail("Not in master or release branch.")
44
45 lines = ctx.run(
46 ctx.c("%s status --porcelain", git), env=dict(LC_ALL="C"), hide=True
47 ).stdout
48 if lines:
49 ctx.fail("Uncommitted changes!")
50
51
52 def add_tag(ctx):
53 """Add release tag"""
54 version = ctx.run("python setup.py --version", hide=True).stdout.strip()
55 git = ctx.shell.frompath("git")
56
57 ctx.run(
58 ctx.c(
59 """
60 %s tag -a -m "Release version %s" -- %s
61 """,
62 git,
63 version,
64 version,
65 ),
66 echo=True,
67 )