Implements weekly upstream rebase cadence automation: - GitLab CI scheduled pipeline (every 6 hours) - Automatic GitHub release detection - JIRA ticket creation via API - Spec file updates with changelog - Automated MR creation with OSCI Bot integration - TEST_MODE support for safe testing Scripts: - check-upstream-release.sh: Poll GitHub API for new releases - create-release-mr.sh: Main automation orchestrator - update-spec.py: Safe spec file updater - create-jira.sh: JIRA API client - test-workflow.sh: Local testing utility Documentation: - scripts/README.md: Technical documentation - AUTOMATION-SETUP.md: Step-by-step setup guide
103 lines
2.1 KiB
Bash
Executable File
103 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Create JIRA issue for bootc release
|
|
# Returns JIRA ticket key (e.g., RHEL-104567) on success
|
|
|
|
set -euo pipefail
|
|
|
|
VERSION="${1:-}"
|
|
UPSTREAM_URL="${2:-}"
|
|
|
|
if [[ -z "$VERSION" ]]; then
|
|
echo "Usage: $0 <version> [upstream_url]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$UPSTREAM_URL" ]]; then
|
|
UPSTREAM_URL="https://github.com/containers/bootc/releases/tag/v${VERSION}"
|
|
fi
|
|
|
|
log_info() {
|
|
echo "[JIRA] $*"
|
|
}
|
|
|
|
log_error() {
|
|
echo "[JIRA ERROR] $*" >&2
|
|
}
|
|
|
|
# Check for required env vars
|
|
if [[ -z "${JIRA_API_TOKEN:-}" ]]; then
|
|
log_error "JIRA_API_TOKEN environment variable not set"
|
|
exit 1
|
|
fi
|
|
|
|
# JIRA API endpoint (v3 as per Red Hat Jira)
|
|
JIRA_API="https://issues.redhat.com/rest/api/3/issue"
|
|
|
|
# Create payload
|
|
SUMMARY="Update bootc to ${VERSION} in CentOS Stream"
|
|
DESCRIPTION="Automated release update from upstream bootc v${VERSION}
|
|
|
|
Upstream release: ${UPSTREAM_URL}
|
|
|
|
This issue was created automatically by bootc-release-bot."
|
|
|
|
PAYLOAD=$(cat <<EOF
|
|
{
|
|
"fields": {
|
|
"project": {
|
|
"key": "RHEL"
|
|
},
|
|
"summary": "$SUMMARY",
|
|
"description": {
|
|
"type": "doc",
|
|
"version": 1,
|
|
"content": [
|
|
{
|
|
"type": "paragraph",
|
|
"content": [
|
|
{
|
|
"type": "text",
|
|
"text": "$DESCRIPTION"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"issuetype": {
|
|
"name": "Story"
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
)
|
|
|
|
log_info "Creating JIRA issue: $SUMMARY"
|
|
|
|
# Make API call
|
|
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
|
-X POST \
|
|
-H "Authorization: Bearer ${JIRA_API_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$PAYLOAD" \
|
|
"$JIRA_API")
|
|
|
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
|
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
|
|
|
if [[ "$HTTP_CODE" -ge 200 ]] && [[ "$HTTP_CODE" -lt 300 ]]; then
|
|
JIRA_KEY=$(echo "$BODY" | jq -r '.key')
|
|
if [[ -n "$JIRA_KEY" ]] && [[ "$JIRA_KEY" != "null" ]]; then
|
|
log_info "Successfully created: $JIRA_KEY"
|
|
echo "$JIRA_KEY"
|
|
exit 0
|
|
else
|
|
log_error "Failed to parse JIRA key from response"
|
|
echo "$BODY" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
log_error "API request failed with HTTP $HTTP_CODE"
|
|
echo "$BODY" >&2
|
|
exit 1
|
|
fi
|