Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions ci/downstream.sh
Original file line number Diff line number Diff line change
@@ -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"
Comment thread
noga-magen marked this conversation as resolved.

# 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."
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"
Loading