Skip to content

Commit

Permalink
Merge pull request openshift#3330 from pmtk/ushift-3139/create-tag-be…
Browse files Browse the repository at this point in the history
…fore-referencing-it

USHIFT-3139: Release notes job: create tag before referencing it
  • Loading branch information
openshift-merge-bot[bot] committed May 8, 2024
2 parents a3063be + 7b01391 commit cdb1cfa
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions scripts/release-notes/gen_ec_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def check_for_new_releases(url_base, release_type, version):
if github_release_exists(release_name):
print("Found an existing release, no work to do")
return None
print("Not found")
print(f"Release tag {release_name} not found on remote repository")

return Release(
release_name,
Expand Down Expand Up @@ -454,6 +454,13 @@ def tag_release(tag, sha, buildtime):
env=env,
check=True,
)


def push_tag(tag):
env = {}
# Include our existing environment settings to ensure values like
# HOME and other git settings are propagated.
env.update(os.environ)
print(f'git push {REMOTE} {tag}')
cmd = ['git', 'push', REMOTE, tag]
completed = subprocess.run(
Expand Down Expand Up @@ -510,6 +517,11 @@ def publish_release(new_release, take_action):
""")

if not tag_exists(release_name):
# release_date looks like 202402022103
buildtime = datetime.datetime.strptime(release_date, '%Y%m%d%H%M')
tag_release(release_name, commit_sha, buildtime)

# Get the previous tag on the branch as the starting point for the
# release notes.
previous_tag = get_previous_tag(release_name)
Expand Down Expand Up @@ -537,10 +549,7 @@ def publish_release(new_release, take_action):
print(notes)
return

if not tag_exists(release_name):
# release_date looks like 202402022103
buildtime = datetime.datetime.strptime(release_date, '%Y%m%d%H%M')
tag_release(release_name, commit_sha, buildtime)
push_tag(release_name)

# Create draft release with message that includes download URLs and history
try:
Expand All @@ -563,11 +572,7 @@ def github_release_create(tag, notes):
draft=False,
prerelease=True,
)
print(f'Created new release {tag}')
print()
print(results['html_url'])
print()
print(results['body'])
print(f'Created new release {tag}:{ {"url":results["html_url"], "body": results["body"]} }')


def github_release_notes(previous_tag, tag_name, target_commitish):
Expand Down Expand Up @@ -597,7 +602,7 @@ def github_api(path, **data):
)
else:
r = request.Request(url=url)
print(r.get_method(), url, data)
print(f"GitHub API Request: { {'method':r.get_method(), 'url': url, 'data': data} }")
r.add_header('Accept', 'application/vnd.github+json')
r.add_header('User-agent', 'microshift-release-notes')
r.add_header('Authorization', f'Bearer {GITHUB_TOKEN}')
Expand Down

0 comments on commit cdb1cfa

Please sign in to comment.