Skip to content

Fix: Self-hosted runner network issues and artifact upload failures #17

Fix: Self-hosted runner network issues and artifact upload failures

Fix: Self-hosted runner network issues and artifact upload failures #17

name: Build SkyChart macOS ARM64 (Self-Hosted)
on:
push:
branches: [ main, master, macos-arm64 ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
permissions:
contents: read
actions: read
checks: write
jobs:
build-self-hosted:
name: Build on Self-hosted macOS ARM64
runs-on: [self-hosted, macOS, ARM64]
timeout-minutes: 45
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup environment info
run: |
echo "🏠 Running on Self-hosted ARM64 runner"
echo "Runner OS: $(uname -a)"
echo "CPU Architecture: $(uname -m)"
echo "🚀 Installing build environment..."
- name: Check and install build dependencies
run: |
echo "� Checking for existing build environment..."
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Homebrew exists, install if not
if ! command_exists brew; then
echo "📦 Homebrew not found, installing..."
# Install Homebrew without sudo (installs to user directory if needed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || {
echo "❌ Failed to install Homebrew"
echo "Please ensure this runner has Homebrew installed or the necessary build tools"
exit 1
}
# Add Homebrew to PATH for this session
if [[ -f "/opt/homebrew/bin/brew" ]]; then
echo "/opt/homebrew/bin" >> $GITHUB_PATH
export PATH="/opt/homebrew/bin:$PATH"
elif [[ -f "/usr/local/bin/brew" ]]; then
echo "/usr/local/bin" >> $GITHUB_PATH
export PATH="/usr/local/bin:$PATH"
fi
else
echo "✅ Homebrew found: $(brew --version | head -1)"
fi
# Check and install FPC
if ! command_exists fpc; then
echo "📦 Installing Free Pascal Compiler..."
brew install fpc || {
echo "❌ Failed to install FPC via Homebrew"
echo "Please ensure FPC is available on this runner"
exit 1
}
else
echo "✅ FPC found: $(fpc -iV)"
fi
# Check and install Qt5
if ! brew list qt@5 >/dev/null 2>&1; then
echo "📦 Installing Qt5..."
brew install qt@5 || {
echo "❌ Failed to install Qt5 via Homebrew"
echo "Please ensure Qt5 is available on this runner"
exit 1
}
else
echo "✅ Qt5 found: $(brew list --versions qt@5)"
fi
echo "✅ All build dependencies verified"
- name: Verify complete build environment
run: |
echo "🔍 Final environment verification..."
# Check all required tools are available
MISSING_TOOLS=()
if ! command -v fpc >/dev/null 2>&1; then
MISSING_TOOLS+=("fpc")
fi
if ! command -v brew >/dev/null 2>&1; then
MISSING_TOOLS+=("brew")
elif ! brew list qt@5 >/dev/null 2>&1; then
MISSING_TOOLS+=("qt@5")
fi
if [[ ${#MISSING_TOOLS[@]} -gt 0 ]]; then
echo "❌ Missing required build tools: ${MISSING_TOOLS[*]}"
echo ""
echo "To set up this self-hosted runner manually:"
echo "1. Install Homebrew: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo "2. Install FPC: brew install fpc"
echo "3. Install Qt5: brew install qt@5"
echo "4. Ensure runner user has permissions for these tools"
echo ""
exit 1
fi
echo "✅ Build environment complete and ready"
echo " FPC: $(fpc -iV) ($(fpc -iTP))"
echo " Qt5: $(brew list --versions qt@5)"
echo " Homebrew: $(brew --version | head -1)"
- name: Setup Qt5 environment
run: |
# Safely get Qt5 prefix with error handling
if command -v brew >/dev/null 2>&1; then
QT5_PREFIX=$(brew --prefix qt@5 2>/dev/null) || {
echo "❌ Failed to get Qt5 prefix from Homebrew"
exit 1
}
else
echo "❌ Homebrew not available for Qt5 prefix detection"
exit 1
fi
# Verify Qt5 installation
if [[ ! -d "$QT5_PREFIX" ]]; then
echo "❌ Qt5 directory not found at: $QT5_PREFIX"
exit 1
fi
# Set environment variables
echo "QT5_DIR=$QT5_PREFIX" >> $GITHUB_ENV
echo "DYLD_FRAMEWORK_PATH=$QT5_PREFIX/lib:$DYLD_FRAMEWORK_PATH" >> $GITHUB_ENV
echo "$QT5_PREFIX/bin" >> $GITHUB_PATH
echo "✅ Qt5 environment configured:"
echo " QT5_DIR: $QT5_PREFIX"
echo " Framework path: $QT5_PREFIX/lib"
echo " Binaries: $QT5_PREFIX/bin"
- name: Run build process
run: |
echo "🏗️ Running build process..."
chmod +x *.sh
export QT5_PREFIX=$(brew --prefix qt@5)
export DYLD_FRAMEWORK_PATH="$QT5_PREFIX/lib:$DYLD_FRAMEWORK_PATH"
export PATH="$QT5_PREFIX/bin:$PATH"
echo "Building dependencies..."
./build_dependencies.sh 2>&1 | tee build_dependencies.log
echo "Building SkyChart..."
./build_macos_arm64.sh 2>&1 | tee build_skychart.log
echo "Testing build..."
./test_build.sh 2>&1 | tee test_build.log || true
echo "Creating package..."
./package_macos.sh all 2>&1 | tee package.log || true
echo "Build artifacts:"
find . -name "skychart" -type f 2>/dev/null || true
ls -la dist/ || true
- name: Code signing and notarization (if configured)
env:
DEVELOPER_ID_APPLICATION: ${{ secrets.DEVELOPER_ID_APPLICATION }}
DEVELOPER_ID_INSTALLER: ${{ secrets.DEVELOPER_ID_INSTALLER }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APP_PASSWORD: ${{ secrets.APP_PASSWORD }}
TEAM_ID: ${{ secrets.TEAM_ID }}
run: |
if [[ -n "$DEVELOPER_ID_APPLICATION" && -n "$APPLE_ID" && -n "$APP_PASSWORD" && -n "$TEAM_ID" ]]; then
echo "🔐 Code signing and notarization enabled"
chmod +x sign_and_notarize_macos.sh
# Find the app bundle
APP_BUNDLE=$(find dist -name "*.app" -type d | head -1)
if [[ -n "$APP_BUNDLE" ]]; then
echo "📱 Found app bundle: $APP_BUNDLE"
./sign_and_notarize_macos.sh "$APP_BUNDLE" 2>&1 | tee signing.log
# List signed artifacts
echo "📦 Signed artifacts:"
ls -la *.dmg 2>/dev/null || echo "No DMG files created"
else
echo "⚠️ No app bundle found in dist/ directory"
fi
else
echo "ℹ️ Code signing skipped - certificates or credentials not configured"
echo "📋 To enable signing, set these repository secrets:"
echo " - DEVELOPER_ID_APPLICATION"
echo " - APPLE_ID"
echo " - APP_PASSWORD"
echo " - TEAM_ID"
echo "📚 See MACOS_SIGNING_SETUP.md for detailed setup instructions"
fi
- name: Upload build artifacts (with fallback)
uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: skychart-macos-arm64-build-${{ github.run_number }}
path: |
skychart/units/**/*
skychart/library/**/*
dist/
*.dmg
*.log
retention-days: 30
- name: Upload signed DMG (with fallback)
uses: actions/upload-artifact@v4
if: success()
continue-on-error: true
with:
name: skychart-macos-arm64-signed-${{ github.run_number }}
path: |
*.dmg
retention-days: 90
- name: Local artifact storage (fallback)
if: failure()
run: |
echo "📦 GitHub artifact upload failed - storing locally..."
# Create local artifact directory
ARTIFACT_DIR="/tmp/skychart-artifacts-${{ github.run_number }}"
mkdir -p "$ARTIFACT_DIR"
# Copy all build artifacts
cp -r skychart/units "$ARTIFACT_DIR/" 2>/dev/null || true
cp -r skychart/library "$ARTIFACT_DIR/" 2>/dev/null || true
cp -r dist "$ARTIFACT_DIR/" 2>/dev/null || true
cp *.dmg "$ARTIFACT_DIR/" 2>/dev/null || true
cp *.log "$ARTIFACT_DIR/" 2>/dev/null || true
# Create archive
ARCHIVE_NAME="skychart-macos-arm64-${{ github.run_number }}.tar.gz"
tar -czf "$ARCHIVE_NAME" -C "$ARTIFACT_DIR" .
echo "📁 Local archive created: $ARCHIVE_NAME"
echo "📏 Archive size: $(du -sh "$ARCHIVE_NAME" | cut -f1)"
echo "📋 Archive contents:"
tar -tzf "$ARCHIVE_NAME" | head -20
# Store archive in accessible location
ACCESSIBLE_DIR="$HOME/Desktop/skychart-builds"
mkdir -p "$ACCESSIBLE_DIR"
cp "$ARCHIVE_NAME" "$ACCESSIBLE_DIR/"
echo "✅ Archive available at: $ACCESSIBLE_DIR/$ARCHIVE_NAME"
echo "🌐 To download from runner machine:"
echo " scp user@runner-host:$ACCESSIBLE_DIR/$ARCHIVE_NAME ."
- name: Network diagnostics
run: |
echo "🔍 Running network diagnostics..."
chmod +x network_diagnostics.sh
./network_diagnostics.sh