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

[deploy_maven] allow for release repo override via command line #350

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

sugarmanz
Copy link
Contributor

@sugarmanz sugarmanz commented Jul 20, 2022

What is the goal of this PR?

Allow for the release repo to be configured dynamically. With Maven Central, there is the opportunity to batch a release with a singular staging repository. Unfortunately, without some rework, it would be a little difficult to dynamically set the release repository. I don't really want to dynamically touch the BUILD or .bzl files where I might have the release_repo defined that is passed into the rule since that could differ between repos. This change allows the release_repo to be overridden from a CLI such that the staging repository can be created dynamically during CI and passed to the deploy target for publishing before dynamically closing & releasing the staging repo.

Related shell script

What are the changes implemented in this PR?

This is an interesting PR b/c there are a few ways to solve this. I could have modified the .py script to try and read from an env var. However, given that this is really a one-off URL, the potential for a stale repo being stored and used from the env was non-zero. Having to manually specify the staging repo w/in the bazel invocation seemed like a good middleground.

Opinions appreciated 😄

allow grouping releases into a single staging repo
Comment on lines +319 to +321
release_repo = ctx.attr.release
if _DEPLOY_MAVEN_RELEASE_REPO_KEY in ctx.var:
release_repo = ctx.var[_DEPLOY_MAVEN_RELEASE_REPO_KEY]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the approach of using --define! This is aligned with how we override the version being deployed:

bazel run --define version=$(cat VERSION) //:deploy-maven -- release

A couple of points:

  1. Since we're allowing users to override the release repo, we should also allow them to override the snapshot repo.
  2. As version is all lowercase, so should be deploy_maven_release_repo; and for terseness, I'd call it just release_repo. (As this is a run target, the key need not be globally unique.)

With all that in mind, and simplifying the Starlark a little:

Suggested change
release_repo = ctx.attr.release
if _DEPLOY_MAVEN_RELEASE_REPO_KEY in ctx.var:
release_repo = ctx.var[_DEPLOY_MAVEN_RELEASE_REPO_KEY]
snapshot_repo = ctx.var.get("snapshot_repo", default=ctx.attr.snapshot)
release_repo = ctx.var.get("release_repo", default=ctx.attr.release)

(requires additional update to L330: "{snapshot}": snapshot_repo,)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants