Philipp Hörist pushed to branch master at gajim / gajim


Commits:
a0fddbde by lovetox at 2022-05-21T12:21:57+02:00
chore: Scripts: Add bump_version script

- - - - -
25dd9431 by lovetox at 2022-05-21T12:24:11+02:00
chore: Update Release.md

- - - - -


2 changed files:

- .gitlab/issue_templates/Release.md
- + scripts/bump_version.py


Changes:

=====================================
.gitlab/issue_templates/Release.md
=====================================
@@ -5,15 +5,13 @@ ## Things to do before release:
 * [ ] xxx
 
 ## Build
-* [ ] Update `ChangeLog`
-* [ ] Raise version in `gajim/__init__.py`
-* [ ] Raise version in  `data/org.gajim.Gajim.appdata.xml.in`
 * [ ] Merge translations from Weblate
+* [ ] Update `ChangeLog`
+* [ ] Run `./scripts/bump_version.py x.x.x`
 * [ ] Push release tag `gajim-x.x.x`
 * [ ] Update Debian repository on gajim.org
 
 ## Update
-* [ ] Notify package maintainers to include new release (announce via mailing 
list)
 * [ ] Website: Write announcement post with changelog
 * [ ] Website: Update Download section on gajim.org (set [current version and 
update installer 
links](https://dev.gajim.org/gajim/website/blob/master/themes/beautifulhugo/data/Gajim.json))
 * [ ] Website: Update screenshots


=====================================
scripts/bump_version.py
=====================================
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+
+import re
+import argparse
+from datetime import datetime
+from pathlib import Path
+
+REPO_DIR = Path(__file__).resolve().parent.parent
+
+
+INIT = REPO_DIR / 'gajim' / '__init__.py'
+FLATPAK = REPO_DIR / 'flatpak' / 'org.gajim.Gajim.yaml'
+APPDATA = REPO_DIR / 'data' / 'org.gajim.Gajim.appdata.xml.in'
+
+VERSION_RX = r"\d+\.\d+\.\d+"
+
+
+def get_current_version() -> str:
+    with INIT.open('r') as f:
+        content = f.read()
+
+    match = re.search(VERSION_RX, content)
+    if match is None:
+        exit('Unable to find current version')
+    return match[0]
+
+
+def bump_init(current_version: str, new_version: str) -> None:
+    with INIT.open('r', encoding='utf8') as f:
+        content = f.read()
+
+    content = content.replace(current_version, new_version, 1)
+
+    with INIT.open('w', encoding='utf8') as f:
+        f.write(content)
+
+
+def bump_flatpak(current_version: str, new_version: str) -> None:
+    with FLATPAK.open('r', encoding='utf8') as f:
+        content = f.read()
+
+    content = content.replace(f'gajim-{current_version}',
+                              f'gajim-{new_version}', 1)
+
+    with FLATPAK.open('w', encoding='utf8') as f:
+        f.write(content)
+
+
+def bump_appdata(new_version: str) -> None:
+    with APPDATA.open('r', encoding='utf8') as f:
+        lines = f.readlines()
+
+    date = datetime.today().strftime('%Y-%m-%d')
+    release_string = f'    <release version="{new_version}" date="{date}" />'
+
+    with APPDATA.open('w', encoding='utf8') as f:
+        for line in lines:
+            f.write(line)
+            if '<releases>' in line:
+                f.write(release_string)
+                f.write('\n')
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description='Bump Version')
+    parser.add_argument('version', help='The new version, e.g. 1.5.0')
+    args = parser.parse_args()
+
+    current_version = get_current_version()
+    bump_init(current_version, args.version)
+    bump_flatpak(current_version, args.version)
+    bump_appdata(args.version)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/dbfef6f461ceee48d55010e867b61db2cfb0e36a...25dd943164b139afa53bbedbf2812baa6d3b5243

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/dbfef6f461ceee48d55010e867b61db2cfb0e36a...25dd943164b139afa53bbedbf2812baa6d3b5243
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to