Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add argument to update version in galaxy.yml file #127

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e13c18d
update basic changes
KB-perByte Jul 5, 2023
670c354
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 5, 2023
f3a6500
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 5, 2023
031c53a
update structure
KB-perByte Jul 5, 2023
1aed28d
make ci happy
KB-perByte Jul 5, 2023
397cdd7
Update src/antsibull_changelog/config.py
KB-perByte Jul 6, 2023
737b4b6
Update changelogs/fragments/update_galaxy.yaml
KB-perByte Jul 6, 2023
f1cad46
Update src/antsibull_changelog/cli.py
KB-perByte Jul 6, 2023
e8aaa90
Update src/antsibull_changelog/cli.py
KB-perByte Jul 6, 2023
39b0186
add review changes
KB-perByte Jul 18, 2023
745bfb0
fix lint
KB-perByte Jul 18, 2023
1cf39a0
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
bdec411
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
884fe25
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
e8e4484
update changes on comparison
KB-perByte Jul 19, 2023
cae00dc
update exceptions
KB-perByte Jul 19, 2023
a4d51e4
isort happy
KB-perByte Jul 19, 2023
abf9f7c
fix lint
KB-perByte Jul 19, 2023
5dbbb30
make conditional
KB-perByte Jul 19, 2023
813db15
refactor
KB-perByte Jul 19, 2023
35fe36e
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
649d53c
format return
KB-perByte Jul 19, 2023
bfda763
fix isort and lint
KB-perByte Jul 19, 2023
7be5797
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Aug 3, 2023
87a686e
Update src/antsibull_changelog/cli.py
KB-perByte Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .fragment import ChangelogFragment, ChangelogFragmentLinter, load_fragments
from .lint import lint_changelog_yaml
from .logger import LOGGER, setup_logger
from .update_galaxy import UpdateGalaxy
from .plugins import PluginDescription, load_plugins
from .toml import has_toml_loader_available, load_toml

Expand Down Expand Up @@ -239,6 +240,11 @@ def create_argparser(program_name: str) -> argparse.ArgumentParser:
release_parser.set_defaults(func=command_release)
release_parser.add_argument("--version", help="override release version")
release_parser.add_argument("--codename", help="override/set release codename")
release_parser.add_argument(
"--update-galaxy-file",
action="store_true",
help="override/set version in galaxy.yml",
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
)
release_parser.add_argument(
"--date", default=str(datetime.date.today()), help="override release date"
)
Expand Down Expand Up @@ -609,7 +615,8 @@ def command_release(args: Any) -> int:
version, codename = _get_version_and_codename(
paths, config, collection_details, args
)

if args.update_galaxy_file:
UpdateGalaxy(paths.galaxy_path, version)
changes = load_changes(config)

prev_version: str | None = None
Expand Down
35 changes: 35 additions & 0 deletions src/antsibull_changelog/update_galaxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Author: Sagar Paul <paul.sagar@yahoo.com>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or
# https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023, Ansible Project

"""
Update version in galaxy.yml.
"""

from __future__ import annotations

from .yaml import load_yaml, store_yaml
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved

KB-perByte marked this conversation as resolved.
Show resolved Hide resolved

class UpdateGalaxy:
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
"""
Load and update galaxy.yaml file.
"""

galaxy_path: str | None
version: str | None

def __init__(self, galaxy_path: str, version: str):
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
self.galaxy_path = galaxy_path
self.version = version
self.update_galaxy_file()

def update_galaxy_file(self) -> None:
"""
Load and update galaxy.yaml file.
"""
config = load_yaml(self.galaxy_path)
config["version"] = str(self.version)
store_yaml(self.galaxy_path, config)
Loading