Skip to content

Commit

Permalink
inject release profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Jul 2, 2024
1 parent 29fc145 commit 154e354
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/mvn_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@ def import_gpg_key(gpg_private_key: str):
)


def add_release_profile(root_path: Path):
namespace = {"maven": maven_namespace}
template_root = xml.parse(Path(__file__).parent / "template/pom.xml").getroot()
template_profiles = template_root.find("maven:profiles", namespace)

if template_profiles is None:
raise Exception("No profiles found in template")

tree = xml.parse(root_path / "pom.xml")
root = tree.getroot()
profiles = root.find("maven:profiles", namespace)

if profiles is None:
root.append(template_profiles)
else:
profiles.append(template_profiles[0])

tree.write(
root_path / "pom.xml",
encoding="utf-8",
xml_declaration=True,
default_namespace=maven_namespace,
)


def publish_mvn_package(
*,
src: Path,
Expand Down Expand Up @@ -89,6 +114,8 @@ def publish_mvn_package(

import_gpg_key(gpg_private_key)

add_release_profile(src)

settings_path = Path(__file__).parent / "settings.xml"

run(
Expand Down
2 changes: 0 additions & 2 deletions src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@
<scm>
<url>[email protected]:mucsi96/publish-tools.git</url>
</scm>

<profiles></profiles>
</project>

0 comments on commit 154e354

Please sign in to comment.