Skip to content

Commit 97e0998

Browse files
committed
🚀 releasing version 2.3.0 @ 2021-08-11 14:59
[skip ci]
1 parent be81639 commit 97e0998

12 files changed

+506
-94
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<!--
2+
Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
-->
15
# Changelog
26

37
<!--
@@ -13,6 +17,22 @@ This project was forked from version 1.7.4 of [mbed-tools-ci-scripts](https://gi
1317

1418
[//]: # (begin_release_notes)
1519

20+
"2.3.0" (2021-08-11)
21+
====================
22+
23+
Features
24+
--------
25+
26+
- Added a command to determine project's version (#202108111437)
27+
28+
29+
Bugfixes
30+
--------
31+
32+
- Dependency upgrade: licenseheaders-lt-0.8.9 (#202108110242)
33+
- Fix bug in determining the new release/beta version (#202108111347)
34+
35+
1636
"2.2.4" (2021-08-11)
1737
====================
1838

continuous_delivery_scripts/_version.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
1111
This file is autogenerated, do not modify by hand.
1212
"""
13-
__version__ = "2.2.4"
14-
COMMIT = "3419789b01c48e806cf32b55fb5eb7834195d7d9"
13+
__version__ = "2.3.0"
14+
COMMIT = "be81639291b9d9f0763a32a6d2bdbd050a48a594"
1515
MAJOR = 2
16-
MINOR = 2
17-
PATCH = 4
16+
MINOR = 3
17+
PATCH = 0

docs/generate_news.html

Lines changed: 9 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ <h1 class="title">Module <code>continuous_delivery_scripts.generate_news</code><
4242
import logging
4343
import os
4444
import subprocess
45-
from auto_version import auto_version_tool
46-
from continuous_delivery_scripts.utils.definitions import CommitType
47-
from continuous_delivery_scripts.utils.git_helpers import LocalProjectRepository
45+
from continuous_delivery_scripts.utils.versioning import calculate_version, determine_version_string
46+
from typing import Optional, Tuple, Dict
47+
4848
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
49-
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
49+
from continuous_delivery_scripts.utils.definitions import CommitType
5050
from continuous_delivery_scripts.utils.filesystem_helpers import cd
51-
from typing import Optional, Tuple, Dict
51+
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
5252

5353
logger = logging.getLogger(__name__)
5454

@@ -64,87 +64,11 @@ <h1 class="title">Module <code>continuous_delivery_scripts.generate_news</code><
6464
(is new version, the new version)
6565
&#34;&#34;&#34;
6666
use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
67-
is_new_version, new_version, version_elements = _calculate_version(commit_type, use_news_files)
67+
is_new_version, new_version, version_elements = calculate_version(commit_type, use_news_files)
6868
_generate_changelog(new_version, use_news_files)
6969
return is_new_version, new_version, version_elements
7070

7171

72-
def _calculate_version(commit_type: CommitType, use_news_files: bool) -&gt; Tuple[bool, Optional[str], Dict[str, str]]:
73-
&#34;&#34;&#34;Calculates the version for the release.
74-
75-
eg. &#34;0.1.2&#34;
76-
77-
Args:
78-
commit_type:
79-
use_news_files: Should the version be dependant on changes recorded in news files
80-
81-
Returns:
82-
Tuple containing
83-
a flag stating whether it is a new version or not
84-
A semver-style version for the latest release
85-
&#34;&#34;&#34;
86-
BUMP_TYPES = {CommitType.DEVELOPMENT: &#34;build&#34;, CommitType.BETA: &#34;prerelease&#34;}
87-
is_release = commit_type == CommitType.RELEASE
88-
enable_file_triggers = True if use_news_files else None
89-
bump = BUMP_TYPES.get(commit_type)
90-
project_config_path = configuration.get_value(ConfigurationVariable.PROJECT_CONFIG)
91-
new_version: Optional[str] = None
92-
is_new_version: bool = False
93-
with cd(os.path.dirname(project_config_path)):
94-
old, new_version, updates = auto_version_tool.main(
95-
release=is_release,
96-
enable_file_triggers=enable_file_triggers,
97-
commit_count_as=bump,
98-
config_path=project_config_path,
99-
)
100-
# Autoversion second returned value is not actually the new version
101-
# There seem to be a bug in autoversion.
102-
# This is why the following needs to be done to determine the version
103-
version_elements = _get_version_elements(updates)
104-
new_version = version_elements.get(auto_version_tool.Constants.VERSION_FIELD, new_version)
105-
is_new_version = old != new_version
106-
logger.info(&#34;:: Determining the new version&#34;)
107-
logger.info(f&#34;Version: {new_version}&#34;)
108-
return is_new_version, new_version, version_elements
109-
110-
111-
def _update_version_string(
112-
commit_type: CommitType, new_version: Optional[str], version_elements: Dict[str, str]
113-
) -&gt; Optional[str]:
114-
&#34;&#34;&#34;Updates the version string for development releases.
115-
116-
Args:
117-
commit_type: commit type
118-
new_version: the new version
119-
version_elements: version elements
120-
&#34;&#34;&#34;
121-
if commit_type == CommitType.DEVELOPMENT:
122-
commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD)
123-
if not commit_count:
124-
with LocalProjectRepository() as git:
125-
commit_count = git.get_commit_count()
126-
return &#34;%s-%s.%s+%s&#34; % (
127-
new_version,
128-
auto_version_tool.config.BUILD_TOKEN,
129-
commit_count,
130-
version_elements.get(auto_version_tool.Constants.COMMIT_FIELD),
131-
)
132-
return new_version
133-
134-
135-
def _get_version_elements(native_version_elements: Dict[str, str]) -&gt; Dict[str, str]:
136-
&#34;&#34;&#34;Determines the different version elements.
137-
138-
Args:
139-
native_version_elements: native version elements as understood by autoversion
140-
&#34;&#34;&#34;
141-
return {
142-
key: native_version_elements[native]
143-
for native, key in auto_version_tool.config.key_aliases.items()
144-
if native in native_version_elements
145-
}
146-
147-
14872
def _generate_changelog(version: Optional[str], use_news_files: bool) -&gt; None:
14973
&#34;&#34;&#34;Creates a towncrier log of the release.
15074

@@ -174,7 +98,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.generate_news</code><
17498
try:
17599
commit_type = CommitType.parse(args.release_type)
176100
is_new_version, new_version, version_elements = version_project(commit_type)
177-
version_to_print = _update_version_string(commit_type, new_version, version_elements)
101+
version_to_print = determine_version_string(commit_type, new_version, version_elements)
178102
print(version_to_print)
179103
except Exception as e:
180104
log_exception(logger, e)
@@ -214,7 +138,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
214138
try:
215139
commit_type = CommitType.parse(args.release_type)
216140
is_new_version, new_version, version_elements = version_project(commit_type)
217-
version_to_print = _update_version_string(commit_type, new_version, version_elements)
141+
version_to_print = determine_version_string(commit_type, new_version, version_elements)
218142
print(version_to_print)
219143
except Exception as e:
220144
log_exception(logger, e)
@@ -248,7 +172,7 @@ <h2 id="returns">Returns</h2>
248172
(is new version, the new version)
249173
&#34;&#34;&#34;
250174
use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
251-
is_new_version, new_version, version_elements = _calculate_version(commit_type, use_news_files)
175+
is_new_version, new_version, version_elements = calculate_version(commit_type, use_news_files)
252176
_generate_changelog(new_version, use_news_files)
253177
return is_new_version, new_version, version_elements</code></pre>
254178
</details>

docs/get_version.html

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<!--
2+
-- Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
3+
-- SPDX-License-Identifier: Apache-2.0
4+
-->
5+
<!doctype html>
6+
<html lang="en">
7+
<head>
8+
<meta charset="utf-8">
9+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
10+
<meta name="generator" content="pdoc 0.9.1" />
11+
<title>continuous_delivery_scripts.get_version API documentation</title>
12+
<meta name="description" content="Determine the project new version." />
13+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
14+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
15+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
16+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
17+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
18+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
19+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
20+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
21+
</head>
22+
<body>
23+
<main>
24+
<article id="content">
25+
<header>
26+
<h1 class="title">Module <code>continuous_delivery_scripts.get_version</code></h1>
27+
</header>
28+
<section id="section-intro">
29+
<p>Determine the project new version.</p>
30+
<details class="source">
31+
<summary>
32+
<span>Expand source code</span>
33+
</summary>
34+
<pre><code class="python">#
35+
# Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
36+
# SPDX-License-Identifier: Apache-2.0
37+
#
38+
&#34;&#34;&#34;Determine the project new version.&#34;&#34;&#34;
39+
import sys
40+
41+
import argparse
42+
import logging
43+
from continuous_delivery_scripts.utils.versioning import calculate_version, determine_version_string
44+
45+
from continuous_delivery_scripts.utils.definitions import CommitType
46+
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
47+
48+
logger = logging.getLogger(__name__)
49+
50+
51+
def get_project_version_string(commit_type: CommitType) -&gt; str:
52+
&#34;&#34;&#34;Determine the project version string.
53+
54+
Args:
55+
commit_type: states what is the type of the commit
56+
57+
58+
Returns:
59+
(is new version, the new version)
60+
&#34;&#34;&#34;
61+
use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
62+
_, new_version, version_elements = calculate_version(commit_type, use_news_files)
63+
version_string = determine_version_string(commit_type, new_version, version_elements)
64+
return version_string
65+
66+
67+
def main() -&gt; None:
68+
&#34;&#34;&#34;Handle command line arguments to determine version string.&#34;&#34;&#34;
69+
parser = argparse.ArgumentParser(description=&#34;Determine project&#39;s version.&#34;)
70+
parser.add_argument(
71+
&#34;-t&#34;, &#34;--release-type&#34;, help=&#34;type of release to perform&#34;, required=True, type=str, choices=CommitType.choices()
72+
)
73+
parser.add_argument(&#34;-v&#34;, &#34;--verbose&#34;, action=&#34;count&#34;, default=0, help=&#34;Verbosity, by default errors are reported.&#34;)
74+
args = parser.parse_args()
75+
set_log_level(args.verbose)
76+
77+
try:
78+
commit_type = CommitType.parse(args.release_type)
79+
version_to_print = get_project_version_string(commit_type)
80+
print(version_to_print)
81+
except Exception as e:
82+
log_exception(logger, e)
83+
sys.exit(1)
84+
85+
86+
if __name__ == &#34;__main__&#34;:
87+
main()</code></pre>
88+
</details>
89+
</section>
90+
<section>
91+
</section>
92+
<section>
93+
</section>
94+
<section>
95+
<h2 class="section-title" id="header-functions">Functions</h2>
96+
<dl>
97+
<dt id="continuous_delivery_scripts.get_version.get_project_version_string"><code class="name flex">
98+
<span>def <span class="ident">get_project_version_string</span></span>(<span>commit_type: <a title="continuous_delivery_scripts.utils.definitions.CommitType" href="utils/definitions.html#continuous_delivery_scripts.utils.definitions.CommitType">CommitType</a>) ‑> str</span>
99+
</code></dt>
100+
<dd>
101+
<div class="desc"><p>Determine the project version string.</p>
102+
<h2 id="args">Args</h2>
103+
<dl>
104+
<dt><strong><code>commit_type</code></strong></dt>
105+
<dd>states what is the type of the commit</dd>
106+
</dl>
107+
<h2 id="returns">Returns</h2>
108+
<p>(is new version, the new version)</p></div>
109+
<details class="source">
110+
<summary>
111+
<span>Expand source code</span>
112+
</summary>
113+
<pre><code class="python">def get_project_version_string(commit_type: CommitType) -&gt; str:
114+
&#34;&#34;&#34;Determine the project version string.
115+
116+
Args:
117+
commit_type: states what is the type of the commit
118+
119+
120+
Returns:
121+
(is new version, the new version)
122+
&#34;&#34;&#34;
123+
use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
124+
_, new_version, version_elements = calculate_version(commit_type, use_news_files)
125+
version_string = determine_version_string(commit_type, new_version, version_elements)
126+
return version_string</code></pre>
127+
</details>
128+
</dd>
129+
<dt id="continuous_delivery_scripts.get_version.main"><code class="name flex">
130+
<span>def <span class="ident">main</span></span>(<span>) ‑> NoneType</span>
131+
</code></dt>
132+
<dd>
133+
<div class="desc"><p>Handle command line arguments to determine version string.</p></div>
134+
<details class="source">
135+
<summary>
136+
<span>Expand source code</span>
137+
</summary>
138+
<pre><code class="python">def main() -&gt; None:
139+
&#34;&#34;&#34;Handle command line arguments to determine version string.&#34;&#34;&#34;
140+
parser = argparse.ArgumentParser(description=&#34;Determine project&#39;s version.&#34;)
141+
parser.add_argument(
142+
&#34;-t&#34;, &#34;--release-type&#34;, help=&#34;type of release to perform&#34;, required=True, type=str, choices=CommitType.choices()
143+
)
144+
parser.add_argument(&#34;-v&#34;, &#34;--verbose&#34;, action=&#34;count&#34;, default=0, help=&#34;Verbosity, by default errors are reported.&#34;)
145+
args = parser.parse_args()
146+
set_log_level(args.verbose)
147+
148+
try:
149+
commit_type = CommitType.parse(args.release_type)
150+
version_to_print = get_project_version_string(commit_type)
151+
print(version_to_print)
152+
except Exception as e:
153+
log_exception(logger, e)
154+
sys.exit(1)</code></pre>
155+
</details>
156+
</dd>
157+
</dl>
158+
</section>
159+
<section>
160+
</section>
161+
</article>
162+
<nav id="sidebar">
163+
<h1>Index</h1>
164+
<div class="toc">
165+
<ul></ul>
166+
</div>
167+
<ul id="index">
168+
<li><h3>Super-module</h3>
169+
<ul>
170+
<li><code><a title="continuous_delivery_scripts" href="index.html">continuous_delivery_scripts</a></code></li>
171+
</ul>
172+
</li>
173+
<li><h3><a href="#header-functions">Functions</a></h3>
174+
<ul class="">
175+
<li><code><a title="continuous_delivery_scripts.get_version.get_project_version_string" href="#continuous_delivery_scripts.get_version.get_project_version_string">get_project_version_string</a></code></li>
176+
<li><code><a title="continuous_delivery_scripts.get_version.main" href="#continuous_delivery_scripts.get_version.main">main</a></code></li>
177+
</ul>
178+
</li>
179+
</ul>
180+
</nav>
181+
</main>
182+
<footer id="footer">
183+
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.1</a>.</p>
184+
</footer>
185+
</body>
186+
</html>

0 commit comments

Comments
 (0)