diff --git a/ci/downstream.sh b/ci/downstream.sh index a649b3b6..09ab6e53 100755 --- a/ci/downstream.sh +++ b/ci/downstream.sh @@ -1,25 +1,28 @@ #!/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}" +VERSION="${1:-1.2.0}" +COLLECTION_ROOT="${2:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" -# 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" +trap 'rm -rf "$_tmp_dir"' EXIT +OUTPUT_DIR="${_tmp_dir}/ansible_collections" -# 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}" +# 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}/" -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" +# 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 from the temporary directory mkdir -p "$OUTPUT_DIR" -ansible-galaxy collection build "$ABSOLUTE_COLLECTION_DIR" --output-path "$OUTPUT_DIR" -echo "Collection build complete. Artifact(s) in $OUTPUT_DIR:" - -ls -lh "$OUTPUT_DIR"/*.tar.gz -echo "Done." \ No newline at end of file +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