Skip to content

Commit

Permalink
allow configuring release-trait to not publish release-commits
Browse files Browse the repository at this point in the history
As (yet)  a(nother) workaround for an inconsistency w.r.t.
ocm-component-descriptor-creation/publishing, allow configuring
release-trait such that it will neither create nor publish
release-commits (both release-commit itself and bump-commit).

If configured like that, release-trait can be added to
head-update-pipelines to thus publish component-descriptors consistent
w/ those published from regular release-jobs.
  • Loading branch information
ccwienk committed Dec 10, 2024
1 parent 610af2b commit e69c7f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
11 changes: 11 additions & 0 deletions concourse/model/traits/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class ReleaseCommitPublishingPolicy(EnumWithDocumentation):
value='tag_and_merge_back',
doc='publish release tag to dead-end and merge back release commit to default branch',
)
SKIP = EnumValueWithDocumentation(
value='skip',
doc='neither create, nor publish either of release- and bump-commits',
)


class TagConflictAction(enum.StrEnum):
Expand Down Expand Up @@ -501,6 +505,13 @@ def process_pipeline_args(self, pipeline_args: JobVariant):
if 'trigger' not in pipeline_args.raw['repo']:
main_repo._trigger = False

# validate publishing to github is disabled if release-commit is disabled
if self.trait.release_commit_publishing_policy() is ReleaseCommitPublishingPolicy.SKIP:
if self.trait.release_on_github():
raise ModelValidationError(
'must disable releasing to github if release-commit is set to `skip`',
)

# validate assets if present
for asset in self.trait.assets:
if not pipeline_args.has_step(asset.step_name):
Expand Down
27 changes: 20 additions & 7 deletions concourse/steps/release.mako
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,23 @@ release_commit_publishing_policy = release_trait.release_commit_publishing_polic
if release_commit_publishing_policy is ReleaseCommitPublishingPolicy.TAG_ONLY:
merge_back = False
push_release_commit = False
create_release_commit = True
bump_commit = True
elif release_commit_publishing_policy is ReleaseCommitPublishingPolicy.TAG_AND_PUSH_TO_BRANCH:
merge_back = False
push_release_commit = True
create_release_commit = True
bump_commit = True
elif release_commit_publishing_policy is ReleaseCommitPublishingPolicy.TAG_AND_MERGE_BACK:
push_release_commit = False
merge_back = True
create_release_commit = True
bump_commit = True
elif release_commit_publishing_policy is ReleaseCommitPublishingPolicy.SKIP:
push_release_commit = False
merge_back = False
create_release_commit = false
bump_commit = False
else:
raise ValueError(release_commit_publishing_policy)
Expand Down Expand Up @@ -379,27 +390,28 @@ upstream_commit_sha = git_helper.fetch_head(
git_helper.rebase(commit_ish=upstream_commit_sha)
% endif
% if create_release_commit:
release_commit = create_release_commit(
git_helper=git_helper,
branch=branch,
version=version_str,
version_interface=version_interface,
version_path=version_path,
% if release_commit_message_prefix:
% if release_commit_message_prefix:
release_commit_message_prefix='${release_commit_message_prefix}',
% endif
% if release_callback_path:
% endif
% if release_callback_path:
release_commit_callback='${release_callback_path}',
release_commit_callback_image_reference=release_commit_callback_image_reference,
% endif
% endif
)
% if push_release_commit:
% if push_release_commit:
git_helper.push(
from_ref=release_commit.hexsha,
to_ref=branch,
)
% endif
% endif
tags = _calculate_tags(
version=version_str,
Expand All @@ -419,6 +431,7 @@ create_and_push_tags(
tags=tags,
release_commit=release_commit,
)
% endif
% if release_trait.release_on_github():
try:
Expand Down Expand Up @@ -529,7 +542,7 @@ except:
release_notes_md = None
% endif
% if version_operation != version.NOOP:
% if version_operation != version.NOOP and bump_commit:
create_and_push_bump_commit(
git_helper=git_helper,
repo_dir=repo_dir,
Expand Down

0 comments on commit e69c7f3

Please sign in to comment.