Skip to content

Commit 4254f23

Browse files
committed
feat: enhance globalhub-release skill with container validation and cross-platform support
- Add Docker/Podman availability verification before make update - Add clear error messages when container engine is not available - Add cross-platform sed syntax support (macOS and Linux) - Remove container engine installation/initialization from script - Update documentation with platform compatibility notes - Improve error handling and user guidance The skill now validates container engines upfront and provides clear guidance without attempting automatic installation. The script automatically detects the OS and uses appropriate sed syntax for both macOS and Linux. Signed-off-by: Meng Yan <[email protected]>
1 parent cca3926 commit 4254f23

File tree

3 files changed

+125
-31
lines changed

3 files changed

+125
-31
lines changed

.claude/skills/globalhub-release/README.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ OPENSHIFT_RELEASE_PATH="$HOME/workspace/openshift-release" RELEASE_NAME="next" .
5050
3. **Fork**: You must have forked https://github.com/openshift/release to your account
5151
4. **Container engine**: Either Docker or Podman running (for `make update`)
5252

53+
## Platform Support
54+
55+
This skill and script are compatible with:
56+
- **macOS** (ARM/Apple Silicon and Intel)
57+
- **Linux** (x86_64)
58+
59+
The script automatically detects the platform and uses the appropriate `sed` syntax.
60+
5361
## What This Skill Does
5462

5563
1. ✅ Detects the latest release branch (e.g., release-2.15)
@@ -60,9 +68,10 @@ OPENSHIFT_RELEASE_PATH="$HOME/workspace/openshift-release" RELEASE_NAME="next" .
6068
6. ✅ Clones or reuses existing openshift/release repository
6169
7. ✅ Updates main branch CI configuration
6270
8. ✅ Creates new release pipeline configuration
63-
9. ✅ Auto-generates presubmits and postsubmits jobs
64-
10. ✅ Commits all changes with proper commit message
65-
11. ✅ Creates pull request to openshift/release
71+
9.**Verifies Docker/Podman availability before proceeding**
72+
10. ✅ Auto-generates presubmits and postsubmits jobs
73+
11. ✅ Commits all changes with proper commit message
74+
12. ✅ Creates pull request to openshift/release
6675

6776
## Version Mapping
6877

@@ -99,17 +108,35 @@ The skill automatically calculates correct versions:
99108
## Troubleshooting
100109

101110
### Container engine not running
102-
**Error**: `Cannot connect to the Docker daemon` or `podman: command not found`
103111

104-
**Solution**: Start Docker Desktop or initialize podman:
105-
```bash
106-
# For Docker
107-
# Start Docker Desktop application
112+
**Error messages you might see:**
113+
```
114+
❌ Error: No container engine found!
115+
116+
Please ensure Docker or Podman is installed and running.
117+
- Docker: Start Docker Desktop application
118+
- Podman: Ensure podman machine is running (podman machine start)
119+
```
108120

109-
# For Podman
110-
podman machine init
111-
podman machine start
121+
Or:
112122
```
123+
❌ Error: Podman is installed but no machine is running
124+
125+
Please start your podman machine:
126+
podman machine start
127+
```
128+
129+
**Solution**:
130+
131+
**For Docker:**
132+
- Start the Docker Desktop application
133+
- Verify it's running: `docker info`
134+
135+
**For Podman:**
136+
- Start your podman machine: `podman machine start`
137+
- Verify it's running: `podman machine list`
138+
139+
**Note**: This script assumes Docker or Podman is already installed and configured. It will not attempt to install or initialize container engines.
113140

114141
### Fork not found
115142
**Error**: `Fork not found`

.claude/skills/globalhub-release/SKILL.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Automates the complete workflow for creating a new Multicluster Global Hub relea
3030
- `OPENSHIFT_RELEASE_PATH`: Local path for openshift/release repo (default: "/tmp/openshift-release")
3131
- `GITHUB_USER`: Auto-detected from git config
3232

33+
## Platform Compatibility
34+
35+
This workflow is compatible with:
36+
- **macOS** (ARM/Apple Silicon and Intel) - Uses `sed -i ""` syntax
37+
- **Linux** (x86_64) - Uses `sed -i` syntax
38+
39+
The script automatically detects the OS and adjusts accordingly.
40+
3341
## Instructions
3442

3543
### Step 1: Detect Latest Release and Determine Next Version
@@ -147,16 +155,38 @@ sed -i "s/IMAGE_TAG: v1\.[0-9]\+\.0/IMAGE_TAG: ${GH_VERSION}/" \
147155
ci-operator/config/stolostron/multicluster-global-hub/stolostron-multicluster-global-hub-${NEXT_RELEASE}.yaml
148156
```
149157

150-
### Step 5: Auto-Generate Job Configurations
158+
### Step 5: Verify Container Engine and Auto-Generate Job Configurations
159+
160+
**First, verify that a container engine is available:**
161+
162+
```bash
163+
# Check for Docker
164+
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
165+
CONTAINER_ENGINE="docker"
166+
echo "✅ Docker is available and running"
167+
# Check for Podman
168+
elif command -v podman >/dev/null 2>&1; then
169+
if podman machine list 2>/dev/null | grep -q "Currently running"; then
170+
CONTAINER_ENGINE="podman"
171+
echo "✅ Podman is available and running"
172+
else
173+
echo "❌ Error: Podman is installed but no machine is running"
174+
echo "Please start your podman machine: podman machine start"
175+
exit 1
176+
fi
177+
else
178+
echo "❌ Error: No container engine found!"
179+
echo "Please ensure Docker or Podman is installed and running"
180+
exit 1
181+
fi
182+
```
151183

152-
Use `make update` to automatically generate presubmits and postsubmits:
184+
**Then use `make update` to automatically generate presubmits and postsubmits:**
153185

154186
```bash
155-
# Check if docker is running, otherwise use podman
156-
if docker info >/dev/null 2>&1; then
187+
if [ "$CONTAINER_ENGINE" = "docker" ]; then
157188
CONTAINER_ENGINE=docker make update
158189
else
159-
# Use podman (default)
160190
make update
161191
fi
162192
```

.claude/skills/globalhub-release/scripts/create-release.sh

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ set -euo pipefail
1313
RELEASE_NAME="${RELEASE_NAME:-next}"
1414
OPENSHIFT_RELEASE_PATH="${OPENSHIFT_RELEASE_PATH:-/tmp/openshift-release}"
1515

16+
# Detect OS and set sed in-place flag
17+
if [[ "$OSTYPE" == "darwin"* ]]; then
18+
# macOS requires -i with empty string
19+
SED_INPLACE=(-i "")
20+
else
21+
# Linux uses -i without argument
22+
SED_INPLACE=(-i)
23+
fi
24+
1625
echo "🚀 Starting Global Hub Release Branch Creation"
1726
echo "================================================"
1827

@@ -123,41 +132,69 @@ NEW_CONFIG="ci-operator/config/stolostron/multicluster-global-hub/stolostron-mul
123132

124133
# Update main branch configuration
125134
echo " Updating main branch configuration..."
126-
sed -i.bak "s/name: \"${PREV_VERSION}\"/name: \"${VERSION}\"/" "$MAIN_CONFIG"
127-
sed -i.bak "s/DESTINATION_BRANCH: ${LATEST_RELEASE}/DESTINATION_BRANCH: ${NEXT_RELEASE}/" "$MAIN_CONFIG"
128-
rm -f "${MAIN_CONFIG}.bak"
135+
sed "${SED_INPLACE[@]}" "s/name: \"${PREV_VERSION}\"/name: \"${VERSION}\"/" "$MAIN_CONFIG"
136+
sed "${SED_INPLACE[@]}" "s/DESTINATION_BRANCH: ${LATEST_RELEASE}/DESTINATION_BRANCH: ${NEXT_RELEASE}/" "$MAIN_CONFIG"
129137
echo " ✅ Updated $MAIN_CONFIG"
130138

131139
# Create new release configuration
132140
echo " Creating $NEXT_RELEASE pipeline configuration..."
133141
cp "$LATEST_CONFIG" "$NEW_CONFIG"
134142

135143
# Update version references in new config
136-
sed -i.bak "s/name: \"${PREV_VERSION}\"/name: \"${VERSION}\"/" "$NEW_CONFIG"
137-
sed -i.bak "s/branch: ${LATEST_RELEASE}/branch: ${NEXT_RELEASE}/" "$NEW_CONFIG"
138-
sed -i.bak "s/release-${PREV_VERSION_SHORT}/release-${VERSION_SHORT}/g" "$NEW_CONFIG"
139-
sed -i.bak "s/IMAGE_TAG: v1\.[0-9]\+\.0/IMAGE_TAG: ${GH_VERSION}/" "$NEW_CONFIG"
140-
rm -f "${NEW_CONFIG}.bak"
144+
sed "${SED_INPLACE[@]}" "s/name: \"${PREV_VERSION}\"/name: \"${VERSION}\"/" "$NEW_CONFIG"
145+
sed "${SED_INPLACE[@]}" "s/branch: ${LATEST_RELEASE}/branch: ${NEXT_RELEASE}/" "$NEW_CONFIG"
146+
sed "${SED_INPLACE[@]}" "s/release-${PREV_VERSION_SHORT}/release-${VERSION_SHORT}/g" "$NEW_CONFIG"
147+
sed "${SED_INPLACE[@]}" "s/IMAGE_TAG: v1\.[0-9]\+\.0/IMAGE_TAG: ${GH_VERSION}/" "$NEW_CONFIG"
141148
echo " ✅ Created $NEW_CONFIG"
142149

143-
# Step 5: Auto-generate job configurations
150+
# Step 5: Verify container engine and auto-generate job configurations
151+
echo ""
152+
echo "📍 Step 5: Verifying container engine availability..."
153+
154+
# Check for Docker
155+
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
156+
CONTAINER_ENGINE="docker"
157+
echo " ✅ Docker is available and running"
158+
# Check for Podman
159+
elif command -v podman >/dev/null 2>&1; then
160+
# Check if podman machine is running
161+
if podman machine list 2>/dev/null | grep -q "Currently running"; then
162+
CONTAINER_ENGINE="podman"
163+
echo " ✅ Podman is available and running"
164+
else
165+
echo " ❌ Error: Podman is installed but no machine is running"
166+
echo ""
167+
echo " Please start your podman machine:"
168+
echo " podman machine start"
169+
echo ""
170+
exit 1
171+
fi
172+
else
173+
echo " ❌ Error: No container engine found!"
174+
echo ""
175+
echo " Please ensure Docker or Podman is installed and running."
176+
echo " - Docker: Start Docker Desktop application"
177+
echo " - Podman: Ensure podman machine is running (podman machine start)"
178+
echo ""
179+
exit 1
180+
fi
181+
144182
echo ""
145-
echo "📍 Step 5: Auto-generating job configurations..."
183+
echo "📍 Step 6: Auto-generating job configurations..."
146184
echo " Running make update (this may take a few minutes)..."
185+
echo " Using $CONTAINER_ENGINE as container engine..."
147186

148-
if docker info >/dev/null 2>&1; then
149-
echo " Using Docker as container engine..."
187+
if [ "$CONTAINER_ENGINE" = "docker" ]; then
150188
CONTAINER_ENGINE=docker make update
151189
else
152-
echo " Using Podman as container engine..."
153190
make update
154191
fi
155192

156193
echo " ✅ Job configurations generated"
157194

158-
# Step 6: Commit and create PR
195+
# Step 7: Commit and create PR
159196
echo ""
160-
echo "📍 Step 6: Committing changes and creating PR..."
197+
echo "📍 Step 7: Committing changes and creating PR..."
161198

162199
# Check if there are changes
163200
if git diff --quiet && git diff --cached --quiet; then

0 commit comments

Comments
 (0)