Skip to content

Commit 65529a5

Browse files
Moves constants to consts file
1 parent 0cda14e commit 65529a5

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

.evergreen.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ tasks:
421421
expansion_name: GH_TOKEN
422422
- func: promote_kubectl_plugin_and_release
423423
vars:
424-
release_version: 9.0.9
425-
staging_commit_sha: 68a45e3b9f9b2b000754926f
424+
release_version: 10.0.5
425+
staging_commit_sha: 68b868714f3de400074793bb
426426

427427
- name: build_test_image
428428
commands:

scripts/release/kubectl_mongodb/python/build_kubectl_plugin.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@
66
from botocore.exceptions import ClientError, NoCredentialsError, PartialCredentialsError
77

88
from lib.base_logger import logger
9+
from scripts.release.kubectl_mongodb.python.consts import *
910
from scripts.release.build.build_info import (
1011
load_build_info,
1112
)
1213
from scripts.release.build.build_scenario import (
1314
BuildScenario,
1415
)
1516

16-
AWS_REGION = "eu-north-1"
17-
KUBECTL_PLUGIN_BINARY_NAME = "kubectl-mongodb"
1817
S3_BUCKET_KUBECTL_PLUGIN_SUBPATH = KUBECTL_PLUGIN_BINARY_NAME
1918

20-
GORELEASER_DIST_DIR = "dist"
21-
22-
2319
def run_goreleaser():
2420
try:
2521
command = ["./goreleaser", "build", "--snapshot", "--clean", "--skip", "post-hooks"]
@@ -154,4 +150,3 @@ def main():
154150

155151
if __name__ == "__main__":
156152
main()
157-
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
AWS_REGION = "eu-north-1"
2+
KUBECTL_PLUGIN_BINARY_NAME = "kubectl-mongodb"
3+
4+
STAGING_S3_BUCKET_NAME = "mongodb-kubernetes-dev"
5+
RELEASE_S3_BUCKET_NAME = "mongodb-kubernetes-staging"
6+
7+
GITHUB_REPO = "mongodb/mongodb-kubernetes"
8+
9+
LOCAL_ARTIFACTS_DIR = "artifacts"
10+
CHECKSUMS_PATH = f"{LOCAL_ARTIFACTS_DIR}/checksums.txt"
11+
12+
GORELEASER_DIST_DIR = "dist"

scripts/release/kubectl_mongodb/python/promote_kubectl_plugin.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,12 @@
1111
from github import Github, GithubException
1212

1313
from lib.base_logger import logger
14+
from scripts.release.kubectl_mongodb.python.consts import *
1415

1516
GITHUB_TOKEN = os.environ.get("GH_TOKEN")
16-
GITHUB_REPO = "mongodb/mongodb-kubernetes"
1717

18-
AWS_REGION = "eu-north-1"
19-
20-
STAGING_S3_BUCKET_NAME = "mongodb-kubernetes-dev"
21-
RELEASE_S3_BUCKET_NAME = "mongodb-kubernetes-staging"
22-
23-
KUBECTL_PLUGIN_BINARY_NAME = "kubectl-mongodb"
2418
S3_BUCKET_KUBECTL_PLUGIN_SUBPATH = KUBECTL_PLUGIN_BINARY_NAME
2519

26-
LOCAL_ARTIFACTS_DIR = "artifacts"
27-
CHECKSUMS_PATH = f"{LOCAL_ARTIFACTS_DIR}/checksums.txt"
28-
29-
3020
def main():
3121
parser = argparse.ArgumentParser()
3222
parser.add_argument(
@@ -51,6 +41,28 @@ def main():
5141

5242
upload_assets_to_github_release(artifacts, args.release_version)
5343

44+
# get_commit_from_tag gets the commit associated with a release tag, so that we can use that
45+
# commit to pull the artifacts from staging bucket.
46+
def get_commit_from_tag(tag: str) -> str:
47+
try:
48+
subprocess.run(
49+
["git", "fetch", "--tags"],
50+
capture_output=True,
51+
text=True,
52+
check=True
53+
)
54+
55+
result = subprocess.run(
56+
["git", "rev-parse", f"{tag}^{{commit}}"], # git rev-parse v1.1.1^{commit}
57+
capture_output=True,
58+
text=True,
59+
check=True
60+
)
61+
return result.stdout.strip()
62+
63+
except subprocess.CalledProcessError as e:
64+
logger.info(f"Failed to get commit for tag: {tag}, err: {e.stderr.strip()}")
65+
sys.exit(1)
5466

5567
# generate_checksums generates checksums for the artifacts that we are going to upload to github release as assets.
5668
# It's formatted: checksum artifact_name
@@ -151,20 +163,15 @@ def sign_and_verify_artifacts():
151163
sys.exit(1)
152164

153165

154-
def artifacts_source_dir_s3(commit_sha: str):
155-
return f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist/"
156-
157-
158-
def artifacts_dest_dir_s3(release_verion: str):
159-
return f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{release_verion}/dist/"
160-
161-
162166
def s3_artifacts_path_to_local_path(release_version: str, commit_sha: str):
167+
s3_common_path = f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist"
163168
return {
164-
f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist/kubectl-mongodb_darwin_amd64_v1/": f"kubectl-mongodb_{release_version}_darwin_amd64",
165-
f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist/kubectl-mongodb_darwin_arm64/": f"kubectl-mongodb_{release_version}_darwin_arm64",
166-
f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist/kubectl-mongodb_linux_amd64_v1/": f"kubectl-mongodb_{release_version}_linux_amd64",
167-
f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/dist/kubectl-mongodb_linux_arm64/": f"kubectl-mongodb_{release_version}_linux_arm64",
169+
f"{s3_common_path}/kubectl-mongodb_darwin_amd64_v1/": f"kubectl-mongodb_{release_version}_darwin_amd64",
170+
f"{s3_common_path}/kubectl-mongodb_darwin_arm64/": f"kubectl-mongodb_{release_version}_darwin_arm64",
171+
f"{s3_common_path}/kubectl-mongodb_linux_amd64_v1/": f"kubectl-mongodb_{release_version}_linux_amd64",
172+
f"{s3_common_path}/kubectl-mongodb_linux_arm64/": f"kubectl-mongodb_{release_version}_linux_arm64",
173+
f"{s3_common_path}/kubectl-mongodb_linux_ppc64le/": f"kubectl-mongodb_{release_version}_linux_ppc64le",
174+
f"{s3_common_path}/kubectl-mongodb_linux_s390x/": f"kubectl-mongodb_{release_version}_linux_s390x",
168175
}
169176

170177

0 commit comments

Comments
 (0)