-
Notifications
You must be signed in to change notification settings - Fork 61
Automate CPE label update in release branch setup script #3536
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
base: main
Are you sure you want to change the base?
Changes from all commits
39fffcc
9f5f176
fb51af7
71a1275
3818448
02c82ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,40 @@ EOT | |
| awk "$awk_query" <(git show main:$MAIN_PR_PIPELINE) > $RELEASE_PR_PIPELINE | ||
| awk "$awk_query" <(git show main:$MAIN_PUSH_PIPELINE) > $RELEASE_PUSH_PIPELINE | ||
|
|
||
| # Set the CPE and name labels in Dockerfile.dist for the release branch. | ||
| # The TAS (Trusted Artifact Signer) version doesn't necessarily follow | ||
| # the Conforma version, so it must be provided explicitly. | ||
| TAS_VERSION="${TAS_VERSION:-}" | ||
| if [[ -z "$TAS_VERSION" ]]; then | ||
| read -rp "Enter the TAS version for this release (e.g. 1.5): " TAS_VERSION | ||
| fi | ||
|
|
||
| if [[ -z "$TAS_VERSION" ]]; then | ||
| echo "Error: TAS version is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$TAS_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: TAS version must be in MAJOR.MINOR format (e.g. 1.5), got: ${TAS_VERSION}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| sed -i.bak -e 's|name="ec"|name="rhtas/ec-rhel9"|' Dockerfile.dist | ||
| rm -f Dockerfile.dist.bak | ||
| sed -i.bak -e "/name=\"rhtas\/ec-rhel9\"/a\\ | ||
| cpe=\"cpe:/a:redhat:trusted_artifact_signer:${TAS_VERSION}::el9\" \\\\" Dockerfile.dist | ||
| rm -f Dockerfile.dist.bak | ||
|
|
||
| grep -q "cpe:/a:redhat:trusted_artifact_signer:${TAS_VERSION}::el9" Dockerfile.dist || { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] correctness grep -q cpe:/a:redhat:trusted_artifact_signer:${TAS_VERSION}::el9 interpolates Suggested fix: Use grep -qF to treat the pattern as a fixed string. |
||
| echo "Error: failed to update Dockerfile.dist labels (pattern not found — file may already be patched, or the label format changed)" | ||
| exit 1 | ||
| } | ||
|
|
||
| echo "Updated Dockerfile.dist labels:" | ||
| echo " name=\"rhtas/ec-rhel9\" \\" | ||
| echo " cpe=\"cpe:/a:redhat:trusted_artifact_signer:${TAS_VERSION}::el9\"" | ||
| echo "" | ||
|
|
||
| echo "To review the new pipeline definitions:" | ||
| echo " vimdiff <(git show main:$MAIN_PR_PIPELINE) $RELEASE_PR_PIPELINE" | ||
| echo " vimdiff <(git show main:$MAIN_PUSH_PIPELINE) $RELEASE_PUSH_PIPELINE" | ||
|
|
@@ -100,4 +134,4 @@ echo " vimdiff <(git show release-v$OLD_VERSION:$OLD_RELEASE_PUSH_PIPELINE) $RE | |
| echo "" | ||
| echo "If the above comparisons look good then you probably want to do this:" | ||
| echo " git rm $MAIN_PR_PIPELINE $MAIN_PUSH_PIPELINE" | ||
| echo " git add $RELEASE_PR_PIPELINE $RELEASE_PUSH_PIPELINE" | ||
| echo " git add $RELEASE_PR_PIPELINE $RELEASE_PUSH_PIPELINE Dockerfile.dist" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[medium] error-handling
read -rp runs unguarded under set -o errexit. In a non-interactive context (CI, stdin closed) read returns non-zero on EOF, which under errexit terminates the script immediately with no output; the intended echo Error: TAS version is required at line 103 is never reached. Callers see a bare non-zero exit with no explanation.
Suggested fix: read -rp "..." TAS_VERSION || true, or guard with if [[ -t 0 ]]; then read -rp ...; fi, so the subsequent [[ -z "$TAS_VERSION" ]] check runs and emits the informative error.