mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-06-26 09:25:24 -06:00
Update find-packages.yml
This commit is contained in:
parent
436d5a669d
commit
4948adf03e
1 changed files with 6 additions and 107 deletions
113
.github/workflows/find-packages.yml
vendored
113
.github/workflows/find-packages.yml
vendored
|
@ -9,110 +9,9 @@ on:
|
|||
type: string
|
||||
|
||||
jobs:
|
||||
discover_conan_packages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Jira Ticket Number Format
|
||||
id: validate_input
|
||||
run: |
|
||||
set -eou pipefail
|
||||
JIRA_TICKET="${{ github.event.inputs.jira_ticket_number }}"
|
||||
# Regex to validate the format: "cura_" followed by one or more digits.
|
||||
# The '^' and '$' anchors ensure the entire string matches the pattern.
|
||||
if [[ ! "$JIRA_TICKET" =~ ^cura_[0-9]+$ ]]; then
|
||||
# Output an error message that will appear as an annotation in the GitHub Actions UI.
|
||||
# This provides immediate and clear feedback to the user about the expected format.
|
||||
echo "::error::Invalid Jira ticket number format. Expected format: cura_# (e.g., cura_12345)."
|
||||
# Exit with a non-zero status code to fail the workflow immediately.
|
||||
exit 1
|
||||
fi
|
||||
echo "Jira ticket number '$JIRA_TICKET' is valid."
|
||||
|
||||
- name: Setup Conan Client
|
||||
uses: conan-io/setup-conan@v1
|
||||
|
||||
- name: Install jq for JSON parsing
|
||||
run: sudo apt-get update && sudo apt-get install -y jq
|
||||
|
||||
- name: Discover Conan Packages
|
||||
id: conan_search
|
||||
env:
|
||||
CONAN_USERNAME: ${{ secrets.CONAN_USERNAME }}
|
||||
CONAN_PASSWORD: ${{ secrets.CONAN_PASSWORD }}
|
||||
run: |
|
||||
set -eou pipefail
|
||||
JIRA_TICKET="${{ github.event.inputs.jira_ticket_number }}"
|
||||
# Construct the full Conan package reference dynamically.
|
||||
# The format '5.11.0-alpha.0@ultimaker/cura_#' is based on the user's requirement.
|
||||
CONAN_PACKAGE_REFERENCE="5.11.0-alpha.0@ultimaker/${JIRA_TICKET}"
|
||||
echo "Searching for Conan packages matching tag: $CONAN_PACKAGE_REFERENCE"
|
||||
|
||||
# Initialize an empty array to store discovered packages.
|
||||
# This array will hold Markdown-formatted strings for the summary.
|
||||
DISCOVERED_PACKAGES=()
|
||||
|
||||
# Get a list of all configured Conan remotes in JSON format.
|
||||
# Conan 2.x's 'conan remote list --format=json' provides structured output.
|
||||
# This dynamic approach ensures the workflow adapts to any remote configuration changes.
|
||||
REMOTES_JSON=$(conan remote list --format=json)
|
||||
|
||||
# Parse the JSON to extract remote names.
|
||||
# The 'jq -r..name' command extracts the 'name' field from each object in the JSON array.
|
||||
REMOTE_NAMES=$(echo "$REMOTES_JSON" | jq -r '..name')
|
||||
|
||||
# Iterate through each remote to perform a targeted search for binaries.
|
||||
# For Conan 2.x, 'conan list' is used for detailed package information.
|
||||
# To find specific binaries, iteration over individual remotes is necessary.
|
||||
for REMOTE_NAME in $REMOTE_NAMES; do
|
||||
echo "Searching remote: $REMOTE_NAME"
|
||||
# Authenticate with the remote if credentials are provided as secrets.
|
||||
# This is a security best practice for private remotes.
|
||||
if [ -n "${CONAN_USERNAME:-}" ] && [ -n "${CONAN_PASSWORD:-}" ]; then
|
||||
echo "Attempting to log in to remote '$REMOTE_NAME'..."
|
||||
conan remote login "$REMOTE_NAME" -u "$CONAN_USERNAME" -p "$CONAN_PASSWORD" || echo "Login failed for remote $REMOTE_NAME, continuing without authentication for this remote."
|
||||
fi
|
||||
# Execute 'conan list' for the specific package reference on the current remote.
|
||||
# The '--format=json' flag ensures machine-readable output.
|
||||
# Redirect stderr to /dev/null to suppress non-critical error messages (e.g., remote not found).
|
||||
SEARCH_RESULT=$(conan list "$CONAN_PACKAGE_REFERENCE" -r "$REMOTE_NAME" --format=json 2>/dev/null || true)
|
||||
|
||||
# Check if any packages were found in this remote's search result.
|
||||
# The '.results.items | select(.recipe.id == "$CONAN_PACKAGE_REFERENCE")'
|
||||
# filters for the exact recipe ID.
|
||||
# '.packages.id' extracts package IDs if binaries are present.
|
||||
FOUND_ITEMS=$(echo "$SEARCH_RESULT" | jq -r --arg ref "$CONAN_PACKAGE_REFERENCE" \
|
||||
'.results.items | select(.recipe.id == $ref) |.packages.id' 2>/dev/null || true)
|
||||
|
||||
if [ -n "$FOUND_ITEMS" ]; then
|
||||
# If packages are found, add them to the DISCOVERED_PACKAGES array.
|
||||
# Format: "- `package/version@user/channel#package_id` (Remote: `remote_name`)"
|
||||
while IFS= read -r PACKAGE_ID; do
|
||||
DISCOVERED_PACKAGES+=("- \`${CONAN_PACKAGE_REFERENCE}#${PACKAGE_ID}\` (Remote: \`${REMOTE_NAME}\`)")
|
||||
done <<< "$FOUND_ITEMS"
|
||||
else
|
||||
echo "No packages found in $REMOTE_NAME matching $CONAN_PACKAGE_REFERENCE"
|
||||
fi
|
||||
done
|
||||
|
||||
# Prepare the summary content for the GitHub Actions run summary.
|
||||
# This content will be written to the GITHUB_STEP_SUMMARY file.
|
||||
echo "### Conan Packages Found for Jira Ticket: ${JIRA_TICKET}" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY" # Add a blank line for spacing
|
||||
echo "The workflow searched for Conan packages tagged \`${CONAN_PACKAGE_REFERENCE}\` across all configured remotes." >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY" # Add a blank line for spacing
|
||||
echo "**Discovered Packages:**" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY" # Add a blank line for spacing
|
||||
|
||||
if [ ${#DISCOVERED_PACKAGES[@]} -eq 0 ]; then
|
||||
echo "*No packages found matching the specified tag.*" >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
# Iterate through the array of discovered packages and append each to the summary file.
|
||||
for PACKAGE_ENTRY in "${DISCOVERED_PACKAGES[@]}"; do
|
||||
echo "$PACKAGE_ENTRY" >> "$GITHUB_STEP_SUMMARY"
|
||||
done
|
||||
fi
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY" # Add a blank line for spacing
|
||||
echo "---" >> "$GITHUB_STEP_SUMMARY" # Add a separator for cleanliness
|
||||
find-packages:
|
||||
name: Find packages for Jira ticket
|
||||
uses: ultimaker/cura-workflows/.github/workflows/find_package_by_ticket.yml@jira_find_package
|
||||
with:
|
||||
jira_ticket_number: ${{ inputs.jira_ticket_number }}
|
||||
secrets: inherit
|
Loading…
Add table
Add a link
Reference in a new issue