From bfe111f2f164beeeb872981707109ce9bad840b2 Mon Sep 17 00:00:00 2001 From: noga-magen Date: Tue, 19 Aug 2025 13:22:50 +0300 Subject: [PATCH 1/2] NO-ISSUE: fixing downstream file name and removing redundant things Signed-off-by: noga-magen --- ci/downstream.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/ci/downstream.sh b/ci/downstream.sh index a649b3b6..9274016c 100755 --- a/ci/downstream.sh +++ b/ci/downstream.sh @@ -1,25 +1,21 @@ #!/usr/bin/env bash set -e -# Get the desired version from a third argument, or default to a fixed version -DESIRED_VERSION="${1:-1.1.0}" +DESIRED_VERSION="${1:-1.2.0}" +COLLECTION_ROOT="${2:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" +GALAXY_YML="$COLLECTION_ROOT/galaxy.yml" -# Output directory for the built collection artifact +# Create a temporary directory and a specific output path _tmp_dir=$(mktemp -d) OUTPUT_DIR="${_tmp_dir}/ansible_collections/redhat/edge_manager" +mkdir -p "$OUTPUT_DIR" -# Get the absolute path of the script directory -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -COLLECTION_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -ABSOLUTE_COLLECTION_DIR="${2:-$COLLECTION_ROOT}" - -GALAXY_YML_PATH="$ABSOLUTE_COLLECTION_DIR/galaxy.yml" -echo "Updating version in $GALAXY_YML_PATH to $DESIRED_VERSION..." -sed -i "s/^version: .*/version: $DESIRED_VERSION/" "$GALAXY_YML_PATH" +# Cleanup - restoring the galaxy.yml and removing the temp directory +trap 'mv "$GALAXY_YML.backup" "$GALAXY_YML" && rm -rf "$_tmp_dir"' EXIT -mkdir -p "$OUTPUT_DIR" -ansible-galaxy collection build "$ABSOLUTE_COLLECTION_DIR" --output-path "$OUTPUT_DIR" -echo "Collection build complete. Artifact(s) in $OUTPUT_DIR:" +# Backup galaxy.yml and modify it +cp "$GALAXY_YML" "$GALAXY_YML.backup" +sed -i "s/^version: .*/version: $DESIRED_VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$GALAXY_YML" -ls -lh "$OUTPUT_DIR"/*.tar.gz -echo "Done." \ No newline at end of file +# Build the collection +ansible-galaxy collection build "$COLLECTION_ROOT" --output-path "$OUTPUT_DIR" \ No newline at end of file From 2b5f9bebda9c5ffbea9da2545f959d871c33860e Mon Sep 17 00:00:00 2001 From: noga-magen Date: Tue, 19 Aug 2025 13:47:49 +0300 Subject: [PATCH 2/2] NO-ISSUE: fixing downstream file name and removing redundant things Signed-off-by: noga-magen --- ci/downstream.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ci/downstream.sh b/ci/downstream.sh index 9274016c..09ab6e53 100755 --- a/ci/downstream.sh +++ b/ci/downstream.sh @@ -1,21 +1,28 @@ #!/usr/bin/env bash set -e -DESIRED_VERSION="${1:-1.2.0}" +VERSION="${1:-1.2.0}" COLLECTION_ROOT="${2:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" -GALAXY_YML="$COLLECTION_ROOT/galaxy.yml" # Create a temporary directory and a specific output path _tmp_dir=$(mktemp -d) -OUTPUT_DIR="${_tmp_dir}/ansible_collections/redhat/edge_manager" -mkdir -p "$OUTPUT_DIR" +trap 'rm -rf "$_tmp_dir"' EXIT +OUTPUT_DIR="${_tmp_dir}/ansible_collections" -# Cleanup - restoring the galaxy.yml and removing the temp directory -trap 'mv "$GALAXY_YML.backup" "$GALAXY_YML" && rm -rf "$_tmp_dir"' EXIT +# Copy the collection source into the temp dir (exclude VCS/build artifacts) +rsync -a --delete \ + --exclude '.git' \ + --exclude '.github' \ + --exclude 'build' \ + --exclude '.tox' \ + --exclude 'venv' \ + --exclude '.venv' \ + "${COLLECTION_ROOT}/" "${_tmp_dir}/" -# Backup galaxy.yml and modify it -cp "$GALAXY_YML" "$GALAXY_YML.backup" -sed -i "s/^version: .*/version: $DESIRED_VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$GALAXY_YML" +# Override metadata for this build +sed "s/^version: .*/version: $VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml" -# Build the collection -ansible-galaxy collection build "$COLLECTION_ROOT" --output-path "$OUTPUT_DIR" \ No newline at end of file +# Build the collection from the temporary directory +mkdir -p "$OUTPUT_DIR" +command -v ansible-galaxy >/dev/null || { echo "ansible-galaxy not found in PATH" >&2; exit 1; } +ansible-galaxy collection build "$_tmp_dir" --output-path "$OUTPUT_DIR" \ No newline at end of file