mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
75 lines
2.2 KiB
Bash
Executable File
75 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
if [[ "$#" -ne 1 ]]; then
|
|
echo "Usage: $0 <version>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
uv run --no-cache --no-project python - "$1" <<'PY'
|
|
from pathlib import Path
|
|
import json
|
|
import re
|
|
import sys
|
|
|
|
version = sys.argv[1]
|
|
if not re.fullmatch(r'\d+\.\d+\.\d+(?:-?rc\d*)?', version):
|
|
raise SystemExit(f'Unsupported version format: {version}')
|
|
|
|
pyproject = Path('pyproject.toml')
|
|
text = pyproject.read_text()
|
|
match = re.search(r'^version = "([^"]+)"$', text, re.MULTILINE)
|
|
if not match:
|
|
raise SystemExit('Failed to find version in pyproject.toml')
|
|
def parse(value):
|
|
base, _, rc = value.replace('-rc', 'rc').partition('rc')
|
|
major, minor, patch = map(int, base.split('.'))
|
|
return major, minor, patch, 0 if 'rc' in value else 1, int(rc or 0)
|
|
if parse(version) <= parse(match.group(1)):
|
|
raise SystemExit(f'New version {version} must be greater than {match.group(1)}')
|
|
updated, count = re.subn(r'^version = "[^"]+"$', f'version = "{version}"', text, count=1, flags=re.MULTILINE)
|
|
if count != 1:
|
|
raise SystemExit('Failed to update version in pyproject.toml')
|
|
updated, count = re.subn(
|
|
r'^current_version = "v[^"]+"$',
|
|
f'current_version = "v{version}"',
|
|
updated,
|
|
count=1,
|
|
flags=re.MULTILINE,
|
|
)
|
|
if count != 1:
|
|
raise SystemExit('Failed to update tool.bumpver.current_version in pyproject.toml')
|
|
pyproject.write_text(updated)
|
|
|
|
package_path = Path('etc/package.json')
|
|
package = json.loads(package_path.read_text())
|
|
package['version'] = version
|
|
package_path.write_text(json.dumps(package, indent=2) + '\n')
|
|
print(version)
|
|
PY
|
|
|
|
uv lock --no-cache
|
|
|
|
uv run --no-cache --no-project python - <<'PY'
|
|
from pathlib import Path
|
|
import re
|
|
import tomllib
|
|
|
|
packages = tomllib.loads(Path('uv.lock').read_text())['package']
|
|
abxpkg_version = next(package['version'] for package in packages if package['name'] == 'abxpkg')
|
|
setup_path = Path('bin/setup.sh')
|
|
setup = setup_path.read_text()
|
|
updated, count = re.subn(
|
|
r'^(ABXPKG_PACKAGE="\$\{ABXPKG_PACKAGE:-abxpkg==)[^}"]+(\}")$',
|
|
rf'\g<1>{abxpkg_version}\g<2>',
|
|
setup,
|
|
count=1,
|
|
flags=re.MULTILINE,
|
|
)
|
|
if count != 1:
|
|
raise SystemExit('Failed to update ABXPKG_PACKAGE in bin/setup.sh')
|
|
setup_path.write_text(updated)
|
|
PY
|