|
| 1 | +name: 'Install and verify dependencies for the Benchmarkoor GitHub Action' |
| 2 | +description: 'Install required dependencies for Benchmarkoor (zip/unzip, GitHub CLI)' |
| 3 | +author: 'ethpandaops' |
| 4 | + |
| 5 | +runs: |
| 6 | + using: 'composite' |
| 7 | + steps: |
| 8 | + - name: Install zip/unzip if not present |
| 9 | + shell: bash |
| 10 | + run: | |
| 11 | + # Check if zip and unzip are available |
| 12 | + ZIP_MISSING=false |
| 13 | + UNZIP_MISSING=false |
| 14 | +
|
| 15 | + if ! command -v zip &> /dev/null; then |
| 16 | + echo "zip command not found" |
| 17 | + ZIP_MISSING=true |
| 18 | + fi |
| 19 | +
|
| 20 | + if ! command -v unzip &> /dev/null; then |
| 21 | + echo "unzip command not found" |
| 22 | + UNZIP_MISSING=true |
| 23 | + fi |
| 24 | +
|
| 25 | + if [ "$ZIP_MISSING" = true ] || [ "$UNZIP_MISSING" = true ]; then |
| 26 | + echo "Installing zip/unzip utilities..." |
| 27 | +
|
| 28 | + # Detect OS |
| 29 | + if [[ "$OSTYPE" == "linux-gnu"* ]]; then |
| 30 | + # Linux - assume Ubuntu/Debian |
| 31 | + sudo apt update |
| 32 | + sudo apt install -y zip unzip |
| 33 | + elif [[ "$OSTYPE" == "darwin"* ]]; then |
| 34 | + # macOS - zip/unzip should be pre-installed, but check with brew if needed |
| 35 | + if command -v brew &> /dev/null; then |
| 36 | + if [ "$ZIP_MISSING" = true ]; then |
| 37 | + brew install zip |
| 38 | + fi |
| 39 | + # unzip is typically pre-installed on macOS |
| 40 | + else |
| 41 | + echo "zip/unzip utilities appear to be missing and Homebrew not found" |
| 42 | + echo "Please install zip/unzip manually" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + else |
| 46 | + echo "Unsupported OS. Please install zip/unzip manually" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | +
|
| 50 | + echo "zip/unzip utilities installed successfully" |
| 51 | + else |
| 52 | + echo "zip and unzip are already available" |
| 53 | + zip --version || true |
| 54 | + unzip -v || true |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Install GitHub CLI if not present |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + if ! command -v gh &> /dev/null; then |
| 61 | + echo "GitHub CLI not found, installing..." |
| 62 | +
|
| 63 | + # Detect OS |
| 64 | + if [[ "$OSTYPE" == "linux-gnu"* ]]; then |
| 65 | + # Linux - assume Ubuntu/Debian |
| 66 | + (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \ |
| 67 | + && mkdir -p -m 755 /etc/apt/keyrings \ |
| 68 | + && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \ |
| 69 | + && cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ |
| 70 | + && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ |
| 71 | + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null |
| 72 | + sudo apt update |
| 73 | + sudo apt install -y gh |
| 74 | + elif [[ "$OSTYPE" == "darwin"* ]]; then |
| 75 | + # macOS |
| 76 | + if command -v brew &> /dev/null; then |
| 77 | + brew install gh |
| 78 | + else |
| 79 | + echo "Homebrew not found. Please install GitHub CLI manually: https://cli.github.com/" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | + else |
| 83 | + echo "Unsupported OS. Please install GitHub CLI manually: https://cli.github.com/" |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | +
|
| 87 | + echo "GitHub CLI installed successfully" |
| 88 | + else |
| 89 | + echo "GitHub CLI already installed" |
| 90 | + gh --version |
| 91 | + fi |
0 commit comments