mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-21 03:54:49 +00:00
chore: tagging tooling; version set to 0.0.1
This commit is contained in:
parent
ab95d66b9b
commit
add68ee746
6 changed files with 186 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "envision"
|
||||
version = "0.1.0"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
<url type="bugtracker">@REPO_URL@/issues</url>
|
||||
<content_rating type="oars-1.0" />
|
||||
<releases>
|
||||
<release version="0.1.0" date="2032-06-18" />
|
||||
<release version="0.0.1" date="2024-11-02">
|
||||
<description>
|
||||
<p>Initial release</p>
|
||||
</description>
|
||||
</release>
|
||||
</releases>
|
||||
<kudos>
|
||||
<!--
|
||||
|
|
32
dist/tagging/metainfo_template.xml
vendored
Normal file
32
dist/tagging/metainfo_template.xml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<release version="{{version}}" date="{{date}}">
|
||||
<description>
|
||||
{% if breaking or features or fixes or other -%}
|
||||
{% if breaking -%}
|
||||
<p>Breaking changes</p>
|
||||
<ul>{% for i in breaking %}
|
||||
<li>{%if i.scope%}{{i.scope}}: {%endif%}{{i.description}}</li>{% endfor %}
|
||||
</ul>
|
||||
{% endif -%}
|
||||
{% if features -%}
|
||||
<p>What's new</p>
|
||||
<ul>{% for i in features %}
|
||||
<li>{%if i.scope%}{{i.scope}}: {%endif%}{{i.description}}</li>{% endfor %}
|
||||
</ul>
|
||||
{% endif -%}
|
||||
{% if fixes -%}
|
||||
<p>Fixes</p>
|
||||
<ul>{% for i in fixes %}
|
||||
<li>{%if i.scope%}{{i.scope}}: {%endif%}{{i.description}}</li>{% endfor %}
|
||||
</ul>
|
||||
{% endif -%}
|
||||
{% if other -%}
|
||||
<p>Other changes</p>
|
||||
<ul>{% for i in other %}
|
||||
<li>{%if i.scope%}{{i.scope}}: {%endif%}{{i.description}}</li>{% endfor %}
|
||||
</ul>
|
||||
{% endif -%}
|
||||
{% else -%}
|
||||
<p>Initial release</p>
|
||||
{% endif -%}
|
||||
</description>
|
||||
</release>
|
122
dist/tagging/release.py
vendored
Executable file
122
dist/tagging/release.py
vendored
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
import os
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
if not os.path.isfile("Cargo.toml") or not os.path.isdir(".git"):
|
||||
eprint("This script needs to run from the root directory of the project")
|
||||
sys.exit(1)
|
||||
|
||||
WHATBUMP_SCRIPT = "./dist/tagging/whatbump.sh"
|
||||
|
||||
if not os.path.isfile(WHATBUMP_SCRIPT):
|
||||
eprint("whatbump script not found")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def cmd(args: List[str]):
|
||||
proc = Popen(args)
|
||||
proc.communicate()
|
||||
retcode = proc.returncode
|
||||
if retcode != 0:
|
||||
raise ValueError(f"Command {" ".join(args)} failed with code {retcode}")
|
||||
|
||||
|
||||
def whatbump():
|
||||
proc = Popen(["bash", WHATBUMP_SCRIPT], stdout=PIPE)
|
||||
(stdout, _) = proc.communicate()
|
||||
retcode = proc.returncode
|
||||
if retcode != 0:
|
||||
raise ValueError(f"whatbump script terminated with code {retcode}")
|
||||
return stdout.decode().strip()
|
||||
|
||||
|
||||
def update_meson_build(tag: str):
|
||||
with open("meson.build", "r") as fd:
|
||||
rows = fd.readlines()
|
||||
rowfound = False
|
||||
for i, row in enumerate(rows):
|
||||
if row.startswith(" version: '") and row.endswith("', # version number row\n"):
|
||||
rows[i] = f" version: '{tag}', # version number row\n"
|
||||
rowfound = True
|
||||
break
|
||||
if not rowfound:
|
||||
eprint("Could not find version row in meson.build")
|
||||
sys.exit(1)
|
||||
with open("meson.build", "w") as fd:
|
||||
fd.writelines(rows)
|
||||
|
||||
|
||||
def update_cargo_toml(tag: str):
|
||||
with open("Cargo.toml", "r") as fd:
|
||||
rows = fd.readlines()
|
||||
rowfound = False
|
||||
for i, row in enumerate(rows):
|
||||
if row.startswith('version = "') and row.endswith('"\n'):
|
||||
rows[i] = f'version = "{tag}"\n'
|
||||
rowfound = True
|
||||
break
|
||||
if not rowfound:
|
||||
eprint("Could not find version row in Cargo.toml")
|
||||
sys.exit(1)
|
||||
with open("Cargo.toml", "w") as fd:
|
||||
fd.writelines(rows)
|
||||
|
||||
|
||||
CHANGELOG_PATH = "./changelog_metainfo.xml"
|
||||
METAINFO_PATH = "./data/org.gabmus.envision.metainfo.xml.in.in"
|
||||
|
||||
|
||||
def update_metainfo(tag: str):
|
||||
with open(CHANGELOG_PATH, "r") as fd:
|
||||
chlog = fd.read()
|
||||
with open(METAINFO_PATH, "r") as fd:
|
||||
rows = fd.readlines()
|
||||
for i, row in enumerate(rows):
|
||||
if "<releases>\n" in row:
|
||||
rows.insert(i + 1, chlog)
|
||||
break
|
||||
with open(METAINFO_PATH, "w") as fd:
|
||||
fd.write("".join(rows))
|
||||
os.unlink(CHANGELOG_PATH)
|
||||
|
||||
|
||||
def yes_no() -> bool:
|
||||
print("Continue? (y/n)")
|
||||
print(">>> ", end="")
|
||||
res = input()
|
||||
return res[0].lower() == "y"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tag = whatbump()
|
||||
print(f"New candidate tag: {tag}")
|
||||
if not yes_no():
|
||||
os.unlink(CHANGELOG_PATH)
|
||||
sys.exit(0)
|
||||
update_meson_build(tag)
|
||||
update_cargo_toml(tag)
|
||||
update_metainfo(tag)
|
||||
cmd(["git", "diff"])
|
||||
commitmsg = f"chore: update version to {tag}"
|
||||
print(f"Will commit with the following message: '{commitmsg}'")
|
||||
if not yes_no():
|
||||
sys.exit(0)
|
||||
cmd(["git", "add", "meson.build", "Cargo.toml", METAINFO_PATH])
|
||||
cmd(["git", "commit", "-m", commitmsg])
|
||||
print(f"Will add tag '{tag}'")
|
||||
if not yes_no():
|
||||
sys.exit(0)
|
||||
cmd(["git", "tag", "-a", tag, "-m", ""])
|
||||
print(f"Will push new commit and tag to origin")
|
||||
if not yes_no():
|
||||
sys.exit(0)
|
||||
cmd(["git", "push"])
|
||||
cmd(["git", "push", "origin", tag])
|
25
dist/tagging/whatbump.sh
vendored
Executable file
25
dist/tagging/whatbump.sh
vendored
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ ! "$(command -v what-bump)" ]; then
|
||||
>&2 cargo install --git https://github.com/sky-uk/what-bump
|
||||
fi
|
||||
if [ ! "$(command -v what-bump)" ]; then
|
||||
>&2 echo "Error: tried installing what-bump, but command is still not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OLD_TAG="$(git describe --tags --abbrev=0 || true)"
|
||||
|
||||
if [ ! "$OLD_TAG" ]; then
|
||||
>&2 echo "No prior tag found, this is the first tag"
|
||||
what-bump HEAD --from 0.0.1 \
|
||||
-c ./changelog_metainfo.xml \
|
||||
-t ./dist/tagging/metainfo_template.xml
|
||||
else
|
||||
rm ./changelog_metainfo.xml || true
|
||||
what-bump "$OLD_TAG" --from "$OLD_TAG" \
|
||||
-c ./changelog_metainfo.xml \
|
||||
-t ./dist/tagging/metainfo_template.xml
|
||||
fi
|
|
@ -1,7 +1,7 @@
|
|||
project(
|
||||
'envision',
|
||||
'rust',
|
||||
version: '0.1.0',
|
||||
version: '0.0.1', # version number row
|
||||
meson_version: '>= 0.59',
|
||||
license: 'AGPL-3.0',
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue