Skip to content

Commit

Permalink
Fix deb version to adhere to LP naming (New) (#714)
Browse files Browse the repository at this point in the history
* Black Changes

* Changed version naming for all lp builds
  • Loading branch information
Hook25 authored Sep 11, 2023
1 parent a1e16c3 commit c647272
Showing 1 changed file with 45 additions and 25 deletions.
70 changes: 45 additions & 25 deletions tools/release/lp-recipe-update-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,27 @@


def main():
parser = ArgumentParser('Invoke a recipe build on specified branch')
parser.add_argument('project',
help="Unique name of the project")
parser.add_argument('--recipe', '-r',
help="Recipe name to build with. If there is only one "
"then that will be used by default, if not then "
"this must be specified.")
parser.add_argument('--new-version', '-n',
help="New version to use in the recipe "
"(for debian changelog) and bzr tags.")
parser = ArgumentParser("Invoke a recipe build on specified branch")
parser.add_argument("project", help="Unique name of the project")
parser.add_argument(
"--recipe",
"-r",
help="Recipe name to build with. If there is only one "
"then that will be used by default, if not then "
"this must be specified.",
)
parser.add_argument(
"--new-version",
"-n",
help="New version to use in the recipe "
"(for debian changelog) and bzr tags.",
)
args = parser.parse_args()

credentials = Credentials.from_string(os.getenv("LP_CREDENTIALS"))
lp = Launchpad(
credentials, None, None, service_root='production', version='devel')
credentials, None, None, service_root="production", version="devel"
)
try:
project = lp.projects[args.project]
except KeyError:
Expand All @@ -72,25 +78,36 @@ def main():
"I don't know which recipe from "
"{project} you want to use, specify "
"one of '{recipes}' using --recipe".format(
project=args.project,
recipes=', '.join(all_recipe_names)))
project=args.project, recipes=", ".join(all_recipe_names)
)
)

# pre-release versions (for us, not tagged daily versions) on LP are denoted
# with ~dev[...] not .dev[...] as setuptools_scm marks them
new_version = args.new_version.replace(".dev", "~dev")

text = build_recipe.recipe_text
# 0.28.0rc1 → 0.28.0~rc1
deb_version = re.sub(r"(rc\d+)$", "~\g<0>", args.new_version)
deb_version = re.sub(r"(rc\d+)$", "~\g<0>", new_version)
# 0.28.0rc1 → 0.28.0_rc1
deb_tag = re.sub(r"(rc\d+)$", "_\g<0>", args.new_version)
text = re.sub(r"deb-version .*?~ppa", "deb-version {}~ppa".format(
deb_version), text)
deb_tag = re.sub(r"(rc\d+)$", "_\g<0>", new_version)
text = re.sub(
r"deb-version .*?~ppa",
"deb-version {}~ppa".format(deb_version),
text,
)
# v0.27.0 → v0.28.0rc1
text = re.sub(r"\bv\d\S+", "v{}".format(args.new_version), text)
text = re.sub(r"\bv\d\S+", "v{}".format(new_version), text)
# debian-0.27.0-1 → debian-0.28.0_rc1-1
text = re.sub(r"debian-(.*)$", "debian-{}-1".format(deb_tag), text)
# {debupstream}+{revtime:monorepo}+git{git-commit:monorepo} → 2.9.dev38+g896ae8978
text = re.sub(r"{debupstream}\S+", args.new_version, text)
# {debupstream}+{revtime:monorepo}+git{git-commit:monorepo} → version
text = re.sub(r"{debupstream}\S+", new_version, text)
# 2.9.dev38+g896ae8978 → 2.9.dev57+g703bc6517
text = re.sub(r"deb-version \d\S+", "deb-version {}".format(
args.new_version), text)
text = re.sub(
r"deb-version \d\S+",
"deb-version {}".format(new_version),
text,
)
build_recipe.recipe_text = text
build_recipe.lp_save()
if build_recipe:
Expand All @@ -99,10 +116,13 @@ def main():
build_recipe.requestBuild(
pocket="Release",
distroseries=series,
archive=build_recipe.daily_build_archive_link)
archive=build_recipe.daily_build_archive_link,
)
except BadRequest:
print("An identical build of this recipe is "
"already pending")
print(
"An identical build of this recipe is "
"already pending"
)
print("Check builds status: " + build_recipe.web_link)


Expand Down

0 comments on commit c647272

Please sign in to comment.