You've already forked hotpocket
BTHLABS-0000: bump-version task
Enough with manual version bumps :D Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .utils import bump_version # noqa: F401
|
||||
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
from invoke import Context, task
|
||||
|
||||
|
||||
@task
|
||||
def bump_version(ctx: Context, next_version: str, build: str | None = None):
|
||||
current_version_result = ctx.run('poetry version -s --no-ansi', hide='out')
|
||||
assert current_version_result is not None, 'Hm?'
|
||||
|
||||
current_version = current_version_result.stdout.strip()
|
||||
|
||||
print(f'Bumping version: `{current_version}` -> `{next_version}`')
|
||||
|
||||
for file_to_version in ctx.config.get('files_to_version', []):
|
||||
with open(file_to_version, 'r', encoding='utf-8') as content_f:
|
||||
content = content_f.read()
|
||||
|
||||
content = content.replace(current_version, next_version)
|
||||
|
||||
with open(file_to_version, 'w', encoding='utf-8') as content_f:
|
||||
content_f.write(content)
|
||||
Reference in New Issue
Block a user