Skip to content

Commit

Permalink
fix yet another property
Browse files Browse the repository at this point in the history
  • Loading branch information
k9ert committed May 29, 2024
1 parent 0e1953c commit d6885e7
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions utils/release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ class ReleaseHelper:
(format: export CI_PIPELINE_ID=<pipeline_id>).
CI_PROJECT_ROOT_NAMESPACE: The root namespace of the CI project
(required for uploading to GitHub).
GH_BIN_UPLOAD_PW: Password or token for GitHub to authenticate uploads.
GH_BIN_UPLOAD_PW: gh_token or token for GitHub to authenticate uploads.
Attributes:
target_dir (str): The directory path where artifacts are to be managed.
tag (str): The git tag associated with the artifacts being managed.
pipeline_id (str): The CI pipeline ID for artifact management operations.
pipeline (Pipeline): A pipeline object fetched from the CI server.
github_project (str): The GitHub repository in which the release should be created or updated.
password (str): The password or token used to authenticate with GitHub.
gh_token (str): The password or token used to authenticate with GitHub.
Methods:
download_and_unpack_all_artifacts(): Downloads and unpacks artifacts from a CI pipeline.
Expand Down Expand Up @@ -269,7 +269,7 @@ def ci_project_id(self):
return self._ci_project_id
if os.environ.get("CI_PROJECT_ID"):
self._ci_project_id = os.environ.get("CI_PROJECT_ID")
logger.info(f"Using ci_project_id: {self.ci_project_id} ")
logger.info(f"Using ci_project_id: {self._ci_project_id} ")
else:
logger.error("No Project given. choose one:")
for project in self.gl.projects.list(search="specter-desktop"):
Expand All @@ -291,6 +291,19 @@ def github_project(self):
logger.info(f"Using github_project: {self._github_project}")
return self._github_project

@property
def gh_token(self):
if hasattr(self, "_gh_token"):
return self._gh_token
if os.environ.get("GH_BIN_UPLOAD_PW"):
self._gh_token = os.environ.get("GH_BIN_UPLOAD_PW")
logger.info(f"Using gh_token: REDACTED")
else:
raise Exception(
"no Github token given ( export GH_BIN_UPLOAD_PW=v0.0.0.0-pre13 )"
)
return self._gh_token

@property
def ci_commit_tag(self):
if hasattr(self, "_ci_commit_tag"):
Expand Down Expand Up @@ -454,28 +467,8 @@ def check_all_sigs(self):
)
logger.info("All files *.asc has valid signatures")

def calculate_publish_params(self):
if not "CI_PROJECT_ROOT_NAMESPACE" in os.environ:
logger.error("CI_PROJECT_ROOT_NAMESPACE not found")
exit(2)
else:
self.github_project = (
f"{os.environ['CI_PROJECT_ROOT_NAMESPACE']}/specter-desktop"
)
if not "CI_COMMIT_TAG" in os.environ:
logger.error("CI_COMMIT_TAG not found")
exit(2)
else:
tag = os.environ["CI_COMMIT_TAG"]
if not "GH_BIN_UPLOAD_PW" in os.environ:
logger.error("GH_BIN_UPLOAD_PW not found.")
exit(2)
else:
self.password = os.environ["GH_BIN_UPLOAD_PW"]

def upload_sha256sum_file(self):
artifact = os.path.join("signing_dir", "SHA256SUMS")
self.calculate_publish_params()

if github.artifact_exists(
self.github_project, self.ci_commit_tag, Path(artifact).name
Expand All @@ -489,12 +482,11 @@ def upload_sha256sum_file(self):
self.ci_commit_tag,
[artifact],
"gitlab_upload_release_binaries",
self.password,
self.gh_token,
)

def upload_sha256sumsig_file(self):
artifact = os.path.join("signing_dir", "SHA256SUMS.asc")
self.calculate_publish_params()

if github.artifact_exists(
self.github_project, self.ci_commit_tag, Path(artifact).name
Expand All @@ -508,7 +500,7 @@ def upload_sha256sumsig_file(self):
self.ci_commit_tag,
[artifact],
"gitlab_upload_release_binaries",
self.password,
self.gh_token,
)


Expand Down

0 comments on commit d6885e7

Please sign in to comment.