mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
Compare commits
20 Commits
1.1.0
...
d6da31b6ff
Author | SHA1 | Date | |
---|---|---|---|
d6da31b6ff | |||
d4f477a544 | |||
a392f09a51 | |||
683ccbf916 | |||
2a67f6edc7 | |||
c4be5d2420 | |||
30947769e1 | |||
6589a91d7e | |||
802633b9a7 | |||
47d4b595f8 | |||
fdf30bc14c | |||
72126c8dca | |||
0666f7f593 | |||
51e28e4ef0 | |||
a7cbacb687 | |||
3fa529a05c | |||
396960fae0 | |||
c661be05dc | |||
2f4124c0fc | |||
465b818ca2 |
16
.github/workflows/python-publish.yml
vendored
16
.github/workflows/python-publish.yml
vendored
@ -9,14 +9,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [ "3.8", "3.9", "3.10" ]
|
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
|
||||||
click-version: [ "click~=7.0", "click~=8.0" ]
|
click-version: [ "click~=8.0" ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4.2.0
|
uses: actions/setup-python@v5.1.1
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ jobs:
|
|||||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4.2.0
|
uses: actions/setup-python@v5.1.1
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '>=3.8'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -75,7 +75,7 @@ jobs:
|
|||||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
|
||||||
- name: Publish to Github
|
- name: Publish to Github
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: dist/*
|
files: dist/*
|
||||||
name: ${{ env.VERSION_TITLE }}
|
name: ${{ env.VERSION_TITLE }}
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
# Required
|
# Required
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
|
# Set the OS, Python version and other tools you might need
|
||||||
|
build:
|
||||||
|
os: ubuntu-22.04
|
||||||
|
tools:
|
||||||
|
python: "3.12"
|
||||||
|
|
||||||
# Build documentation in the docs/ directory with Sphinx
|
# Build documentation in the docs/ directory with Sphinx
|
||||||
sphinx:
|
sphinx:
|
||||||
configuration: docs/conf.py
|
configuration: docs/conf.py
|
||||||
@ -16,7 +22,6 @@ formats:
|
|||||||
|
|
||||||
# Optionally set the version of Python and requirements required to build your docs
|
# Optionally set the version of Python and requirements required to build your docs
|
||||||
python:
|
python:
|
||||||
version: 3.8
|
|
||||||
install:
|
install:
|
||||||
- method: pip
|
- method: pip
|
||||||
path: .
|
path: .
|
||||||
|
34
CHANGELOG.md
34
CHANGELOG.md
@ -2,6 +2,40 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file
|
All notable changes to this project will be documented in this file
|
||||||
|
|
||||||
|
## Version 1.3.0 - 2024-08-08
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- added a `--version` option to `yaclog show` that prints just the version number
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- removed support for Click 7 as a dependency
|
||||||
|
|
||||||
|
|
||||||
|
## Version 1.2.0 - 2024-04-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- added the `-s` option to `yaclog release` to increment arbitrary version segments
|
||||||
|
- added the `-n` option to `yaclog release` to create a new release instead of releasing a new one
|
||||||
|
- added the `-y` option to `yaclog release` to answer "yes" to all confirmation dialogs. Use with caution!
|
||||||
|
|
||||||
|
|
||||||
|
## Version 1.1.2 - 2022-12-29
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- yaclog now only tries to use git when invoked with a command that needs it, meaning most sub commands can now be used on systems without git
|
||||||
|
|
||||||
|
|
||||||
|
## Version 1.1.1 - 2022-08-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `yaclog release -C -c` not committing changes to cargo.toml
|
||||||
|
|
||||||
|
|
||||||
## Version 1.1.0 - 2022-08-14
|
## Version 1.1.0 - 2022-08-14
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools>=61",
|
"setuptools>=64",
|
||||||
"setuptools_scm>=6.2",
|
"setuptools_scm>=8",
|
||||||
"wheel"
|
"wheel"
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
@ -29,7 +29,7 @@ classifiers = [
|
|||||||
|
|
||||||
requires-python = ">= 3.8"
|
requires-python = ">= 3.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Click >= 7.0",
|
"Click >= 8.0",
|
||||||
"GitPython >= 3",
|
"GitPython >= 3",
|
||||||
"packaging >= 20",
|
"packaging >= 20",
|
||||||
"tomlkit >= 0.11"
|
"tomlkit >= 0.11"
|
||||||
|
@ -153,6 +153,11 @@ class TestRelease(unittest.TestCase):
|
|||||||
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.1')
|
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.1')
|
||||||
self.assertIn('1.0.1', result.output)
|
self.assertIn('1.0.1', result.output)
|
||||||
|
|
||||||
|
result = runner.invoke(cli, ['release', '-y', '-s', 2])
|
||||||
|
check_result(self, result)
|
||||||
|
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.2')
|
||||||
|
self.assertIn('1.0.2', result.output)
|
||||||
|
|
||||||
runner.invoke(cli, ['entry', '-b', 'entry number 3'])
|
runner.invoke(cli, ['entry', '-b', 'entry number 3'])
|
||||||
|
|
||||||
result = runner.invoke(cli, ['release', '-m'])
|
result = runner.invoke(cli, ['release', '-m'])
|
||||||
@ -194,6 +199,12 @@ class TestRelease(unittest.TestCase):
|
|||||||
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0')
|
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0')
|
||||||
self.assertIn('3.0.0', result.output)
|
self.assertIn('3.0.0', result.output)
|
||||||
|
|
||||||
|
result = runner.invoke(cli, ['release', '-p', '-n'])
|
||||||
|
check_result(self, result)
|
||||||
|
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.1')
|
||||||
|
self.assertEqual(yaclog.read(location).versions[1].name, '3.0.0')
|
||||||
|
self.assertIn('3.0.1', result.output)
|
||||||
|
|
||||||
def test_commit(self):
|
def test_commit(self):
|
||||||
"""Test committing and tagging releases"""
|
"""Test committing and tagging releases"""
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os.path
|
import os.path
|
||||||
from ..cli import cargo_toml
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import git
|
|
||||||
|
|
||||||
import yaclog.version
|
import yaclog.version
|
||||||
from yaclog.changelog import Changelog
|
from yaclog.changelog import Changelog
|
||||||
@ -52,7 +50,7 @@ def init(obj: Changelog):
|
|||||||
click.echo(f'Created new changelog file at {obj.path}')
|
click.echo(f'Created new changelog file at {obj.path}')
|
||||||
|
|
||||||
|
|
||||||
@cli.command('format') # dont accidentally hide the `format` python builtin
|
@cli.command('format') # don't accidentally hide the `format` python builtin
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def reformat(obj: Changelog):
|
def reformat(obj: Changelog):
|
||||||
"""Reformat the changelog file."""
|
"""Reformat the changelog file."""
|
||||||
@ -72,6 +70,8 @@ def reformat(obj: Changelog):
|
|||||||
help='Show only the version body.')
|
help='Show only the version body.')
|
||||||
@click.option('--header', '-h', 'mode', flag_value='header',
|
@click.option('--header', '-h', 'mode', flag_value='header',
|
||||||
help='Show only the version header.')
|
help='Show only the version header.')
|
||||||
|
@click.option('--version', '-v', 'mode', flag_value='version', help='Show only the version number. If the current version is unreleased, '
|
||||||
|
'this is inferred by incrementing the patch number of the last released version')
|
||||||
@click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
|
@click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
||||||
@ -86,15 +86,22 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
|||||||
'name': (lambda v, k: v.name),
|
'name': (lambda v, k: v.name),
|
||||||
'body': (lambda v, k: v.body(**k)),
|
'body': (lambda v, k: v.body(**k)),
|
||||||
'header': (lambda v, k: v.header(**k)),
|
'header': (lambda v, k: v.header(**k)),
|
||||||
|
'version': (lambda v, k: str(v.version))
|
||||||
}
|
}
|
||||||
|
|
||||||
str_func = functions[mode]
|
str_func = functions[mode]
|
||||||
|
kwargs = {'md': markdown, 'color': True}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if all_versions:
|
if all_versions:
|
||||||
versions = obj.versions
|
versions = obj.versions
|
||||||
elif len(version_names) == 0:
|
elif len(version_names) == 0:
|
||||||
versions = [obj.current_version()]
|
versions = [obj.current_version()]
|
||||||
|
if mode == 'version' and versions[0].name == 'Unreleased':
|
||||||
|
latest = obj.current_version(released=True).version
|
||||||
|
inferred = yaclog.version.increment_version(str(latest), 2, '')
|
||||||
|
print(str(inferred))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
versions = [obj.get_version(name) for name in version_names]
|
versions = [obj.get_version(name) for name in version_names]
|
||||||
except KeyError as k:
|
except KeyError as k:
|
||||||
@ -102,8 +109,6 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
|||||||
except ValueError as v:
|
except ValueError as v:
|
||||||
raise click.ClickException(str(v))
|
raise click.ClickException(str(v))
|
||||||
|
|
||||||
kwargs = {'md': markdown, 'color': True}
|
|
||||||
|
|
||||||
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
|
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
|
||||||
click.echo(sep.join([str_func(v, kwargs) for v in versions]))
|
click.echo(sep.join([str_func(v, kwargs) for v in versions]))
|
||||||
|
|
||||||
@ -189,6 +194,8 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name):
|
|||||||
help='Increment minor version number.')
|
help='Increment minor version number.')
|
||||||
@click.option('-p', '--patch', 'rel_seg', flag_value=2, type=int,
|
@click.option('-p', '--patch', 'rel_seg', flag_value=2, type=int,
|
||||||
help='Increment patch number.')
|
help='Increment patch number.')
|
||||||
|
@click.option('-s', '--segment', 'rel_seg', type=int,
|
||||||
|
help='Increment nth segment of the version. For example, `--segment 2` is equivalent to `--patch`')
|
||||||
@click.option('-a', '--alpha', 'pre_seg', flag_value='a', type=str, default=None,
|
@click.option('-a', '--alpha', 'pre_seg', flag_value='a', type=str, default=None,
|
||||||
help='Increment alpha version number.')
|
help='Increment alpha version number.')
|
||||||
@click.option('-b', '--beta', 'pre_seg', flag_value='b', type=str,
|
@click.option('-b', '--beta', 'pre_seg', flag_value='b', type=str,
|
||||||
@ -202,9 +209,13 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name):
|
|||||||
'If there are no changes to commit, the current commit will be tagged instead.')
|
'If there are no changes to commit, the current commit will be tagged instead.')
|
||||||
@click.option('-C', '--cargo', '-🦀', is_flag=True,
|
@click.option('-C', '--cargo', '-🦀', is_flag=True,
|
||||||
help='Update the version in a Rust cargo.toml manifest file.')
|
help='Update the version in a Rust cargo.toml manifest file.')
|
||||||
|
@click.option('-y', '--yes', is_flag=True,
|
||||||
|
help='Answer "yes" to all confirmation dialogs')
|
||||||
|
@click.option('-n', '--new', is_flag=True,
|
||||||
|
help = 'Create a new version instead of renaming an existing one')
|
||||||
@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False)
|
@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo, yes, new):
|
||||||
"""
|
"""
|
||||||
Release VERSION, or a version incremented from the last release.
|
Release VERSION, or a version incremented from the last release.
|
||||||
|
|
||||||
@ -220,6 +231,9 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
click.echo('Nothing to release!')
|
click.echo('Nothing to release!')
|
||||||
raise click.Abort
|
raise click.Abort
|
||||||
|
|
||||||
|
if new:
|
||||||
|
cur_version = obj.add_version()
|
||||||
|
else:
|
||||||
cur_version = obj.current_version()
|
cur_version = obj.current_version()
|
||||||
old_name = cur_version.name
|
old_name = cur_version.name
|
||||||
|
|
||||||
@ -237,7 +251,7 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
new_name = yaclog.version.increment_version(new_name, rel_seg, pre_seg)
|
new_name = yaclog.version.increment_version(new_name, rel_seg, pre_seg)
|
||||||
|
|
||||||
if new_name != old_name:
|
if new_name != old_name:
|
||||||
if yaclog.version.is_release(old_name):
|
if yaclog.version.is_release(old_name) and not yes:
|
||||||
click.confirm(
|
click.confirm(
|
||||||
f"Rename release version {click.style(old_name, fg='blue')} "
|
f"Rename release version {click.style(old_name, fg='blue')} "
|
||||||
f"to {click.style(new_name, fg='blue')}?",
|
f"to {click.style(new_name, fg='blue')}?",
|
||||||
@ -254,10 +268,12 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
short_version = cur_version.name.replace(' ', '-')
|
short_version = cur_version.name.replace(' ', '-')
|
||||||
|
|
||||||
if cargo:
|
if cargo:
|
||||||
|
from ..cli import cargo_toml
|
||||||
cargo_toml.set_version("Cargo.toml", str(short_version))
|
cargo_toml.set_version("Cargo.toml", str(short_version))
|
||||||
click.echo("Updated Cargo.toml")
|
click.echo("Updated Cargo.toml")
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
|
import git
|
||||||
repo = git.Repo(os.curdir)
|
repo = git.Repo(os.curdir)
|
||||||
|
|
||||||
if repo.bare:
|
if repo.bare:
|
||||||
@ -265,6 +281,9 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
|
|
||||||
repo.index.add(obj.path)
|
repo.index.add(obj.path)
|
||||||
|
|
||||||
|
if cargo:
|
||||||
|
repo.index.add("Cargo.toml")
|
||||||
|
|
||||||
tracked = len(repo.index.diff(repo.head.commit))
|
tracked = len(repo.index.diff(repo.head.commit))
|
||||||
untracked = len(repo.index.diff(None))
|
untracked = len(repo.index.diff(None))
|
||||||
|
|
||||||
@ -280,6 +299,7 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
f"You have {untracked} untracked file{'s'[:untracked]} that will not be included!",
|
f"You have {untracked} untracked file{'s'[:untracked]} that will not be included!",
|
||||||
fg='red', bold=True))
|
fg='red', bold=True))
|
||||||
|
|
||||||
|
if not yes:
|
||||||
click.confirm(' '.join(message), abort=True)
|
click.confirm(' '.join(message), abort=True)
|
||||||
|
|
||||||
if tracked > 0:
|
if tracked > 0:
|
||||||
@ -288,6 +308,7 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
else:
|
else:
|
||||||
commit = repo.head.commit
|
commit = repo.head.commit
|
||||||
|
|
||||||
|
# noinspection PyTypeChecker
|
||||||
repo_tag = repo.create_tag(short_version, ref=commit, message=cur_version.body(False))
|
repo_tag = repo.create_tag(short_version, ref=commit, message=cur_version.body(False))
|
||||||
click.echo(f"Created tag {click.style(repo_tag.name, fg='green')}.")
|
click.echo(f"Created tag {click.style(repo_tag.name, fg='green')}.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user