update: the history of the package is CHANGELOG.md, from which the build writes debian/changelog, the build, publish and development scripts are in Python, and the development tools keep their settings and credentials in .lm-dev-config.
Release / release (push) Failing after 14m43s

This commit is contained in:
slawek committed 2026-11-24 06:51:04 +01:00
1 parent a7bfabcb89
commit 6911d16fa3
26 files changed
+1966 -2105

No files matched your search

+70 -60
View File
@@ -1,25 +1,39 @@
#!/usr/bin/env python3
"""Commit everything, tag the version of the newest changelog entry and push main with the tags.
"""Commit everything with the summary of the newest CHANGELOG.md entry; with --push, tag its version and push main and the tag.
The tag is the version of the first entry of debian-package/debian/changelog, without the
Debian revision 1: linux-manager (0.5.1-1) is tagged 0.5.1 and (0.5.1-2) 0.5.1-2. The tag
starts the release workflow. Once the release succeeds, .dev-build.serial, the serial of the last
dev build (bin/lm-dev-build.py), is written as 0, so the dev builds of the next entry start at
~dev1.
The newest entry of CHANGELOG.md (bin/changelog.py reads it) is released: its heading gets the
current time, "## 0.5.1 - 2026-11-24 10:00:00 +0100", and everything is committed with its summary
paragraph, its lines joined, as the message. The commit marks the entry as released: a second run
for the same entry is refused, and the next change needs a new entry. With --push, the version of
the heading is tagged, 0.5.1 or 0.5.1-2, and main and the tag are pushed in one atomic push; the tag
starts the release workflow. With --no-tag, the entry is an internal release: it is committed as
without --push, and --push pushes main without a tag. debian/changelog is not kept in the
repository; the build writes it from CHANGELOG.md.
Once a release is committed, LXD_DEV_BUILD_SERIAL of .lm-dev-config/settings.json, the serial of
the last dev build (bin/lm-dev-build.py), is written as 0 when the file exists, so the dev builds
of the next entry start at ~dev1. -n prints what would change and the git commands instead.
"""
import argparse
import datetime
import json
import pathlib
import shlex
import subprocess
import sys
ROOT = pathlib.Path(__file__).resolve().parent
CHANGELOG = ROOT / 'debian-package' / 'debian' / 'changelog'
DEV_SERIAL = ROOT / '.dev-build.serial'
sys.path.insert(0, str(ROOT / 'bin'))
import changelog # noqa: E402
CHANGELOG = ROOT / 'CHANGELOG.md'
#: The settings of the lm-dev scripts, which hold LXD_DEV_BUILD_SERIAL.
DEV_SETTINGS = ROOT / '.lm-dev-config' / 'settings.json'
#: Print the git commands instead of running them; set by -n/--dry-run.
#: Print the changes and the git commands instead of making them; set by -n/--dry-run.
DRY_RUN = False
@@ -34,67 +48,63 @@ def git(*args):
sys.exit(result.returncode)
def summary():
"""The summary of the first changelog entry joined into one line, or None when it has none.
The summary is the entry's first paragraph: lines indented by exactly two spaces, the
first not a "*" item, with a blank line between it and the header and a blank line after it.
"""
lines = CHANGELOG.read_text(encoding='utf-8').splitlines()
if len(lines) < 4 or lines[1].strip():
return None
paragraph = []
for line in lines[2:]:
if not line.strip():
break
if not line.startswith(' ') or line.startswith(' ') or line.startswith(' -- '):
return None
paragraph.append(line.strip())
else:
return None
if not paragraph or paragraph[0].startswith('*'):
return None
return ' '.join(paragraph)
def version():
"""The tag of the first changelog entry: its version, without the Debian revision when that is 1."""
first = CHANGELOG.read_text(encoding='utf-8').splitlines()[0]
start, end = first.find('('), first.find(')')
if start == -1 or end < start:
sys.exit(f'{CHANGELOG}: the first line has no version: {first}')
full = first[start + 1:end]
upstream, _, revision = full.rpartition('-')
return upstream if upstream and revision == '1' else full
def main():
global DRY_RUN
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument('-m', '--message', help='commit message; default: the summary of the newest changelog entry, a paragraph not starting with "*" between blank lines right after its header')
parser.add_argument('-n', '--dry-run', action='store_true', help='print the git commands instead of running them')
parser.add_argument('--no-push', action='store_true', help='commit and tag, but do not push')
parser.add_argument('-n', '--dry-run', action='store_true',
help='print the changes and the git commands instead of making them')
parser.add_argument('--push', action='store_true', help='also tag the release and push main and the tag')
parser.add_argument('--no-tag', action='store_true',
help='make an internal release: with --push, push main alone, without a tag')
args = parser.parse_args()
DRY_RUN = args.dry_run
message = args.message or summary()
if not message:
sys.exit(f'no commit message: pass -m, or start the newest entry of {CHANGELOG} with a summary paragraph '
'not starting with "*", indented by two spaces, with a blank line above and below it')
tag = version()
text = CHANGELOG.read_text(encoding='utf-8')
try:
found = changelog.entries(text)
except ValueError as error:
sys.exit(f'{CHANGELOG}: {error}')
if not found or not found[0]['summary']:
sys.exit(f'start the newest entry of {CHANGELOG} with a summary paragraph between blank lines right after '
'its heading')
newest = found[0]
message, tag = newest['summary'], newest['version']
if subprocess.run(['git', 'rev-parse', '-q', '--verify', f'refs/tags/{tag}'], cwd=ROOT,
capture_output=True).returncode == 0:
sys.exit(f'tag {tag} exists; add a new changelog entry first')
git('add', '-A')
git('commit', '-m', message)
git('tag', tag)
if not args.no_push:
git('push', 'origin', 'main', '--tags')
if DRY_RUN:
print(f'echo 0 > {shlex.quote(str(DEV_SERIAL))}')
else:
DEV_SERIAL.write_text('0\n', encoding='utf-8')
log = subprocess.run(['git', 'log', '--format=%s'], cwd=ROOT, capture_output=True, text=True)
committed = log.returncode == 0 and message in log.stdout.splitlines()
dirty = subprocess.run(['git', 'status', '--porcelain'], cwd=ROOT, capture_output=True,
text=True).stdout.strip() != ''
if committed and dirty:
sys.exit(f'{tag} is released; add a new changelog entry for the changes')
if committed and not args.push:
sys.exit(f'{tag} is released; add a new changelog entry, or publish it with --push')
if not committed and not dirty:
sys.exit(f'nothing to commit for {tag}')
if not committed:
if newest['date'] is None:
heading = f'## {tag} - {datetime.datetime.now().astimezone().strftime(changelog.DATE_FORMAT)}'
if DRY_RUN:
print(f'# {CHANGELOG.name}: {heading}')
else:
lines = text.splitlines(keepends=True)
lines[newest['line']] = heading + '\n'
CHANGELOG.write_text(''.join(lines), encoding='utf-8')
git('add', '-A')
git('commit', '-m', message)
if DRY_RUN:
print(f'# LXD_DEV_BUILD_SERIAL of {DEV_SETTINGS} set to 0')
elif DEV_SETTINGS.is_file():
settings = json.loads(DEV_SETTINGS.read_text(encoding='utf-8'))
settings['LXD_DEV_BUILD_SERIAL'] = 0
DEV_SETTINGS.write_text(json.dumps(settings, indent=2) + '\n', encoding='utf-8')
if args.push and args.no_tag:
git('push', 'origin', 'main')
elif args.push:
git('tag', tag)
git('push', '--atomic', 'origin', 'main', tag)
return 0