|
1 | 1 | name: setup-hacklang |
2 | 2 | description: Install HHVM and set up the Hack programming language environment |
3 | 3 | author: CodeWithSushil |
| 4 | + |
4 | 5 | inputs: |
5 | 6 | hhvm-version: |
6 | 7 | description: The version of HHVM/Hack to install |
7 | | - required: true |
| 8 | + required: false |
8 | 9 | default: latest |
9 | 10 |
|
10 | 11 | branding: |
11 | | - icon: 'code' |
| 12 | + icon: code |
12 | 13 | color: purple |
13 | 14 |
|
14 | 15 | runs: |
15 | 16 | using: composite |
16 | 17 | steps: |
17 | | - - name: Install HHVM |
| 18 | + - name: Install HHVM / Hack |
| 19 | + shell: bash |
18 | 20 | run: | |
19 | 21 | set -euxo pipefail |
20 | 22 |
|
21 | 23 | sudo apt-get update |
22 | | - sudo apt-get install -y curl gnupg lsb-release ca-certificates composer php |
| 24 | + sudo apt-get install -y \ |
| 25 | + curl \ |
| 26 | + gnupg \ |
| 27 | + ca-certificates \ |
| 28 | + lsb-release |
23 | 29 |
|
24 | 30 | sudo mkdir -p /usr/share/keyrings |
25 | 31 |
|
| 32 | + # Add HHVM GPG key |
26 | 33 | curl -fsSL https://dl.hhvm.com/conf/hhvm.gpg.key | \ |
27 | | - gpg --dearmor | sudo tee /usr/share/keyrings/hhvm.gpg > /dev/null |
| 34 | + gpg --dearmor | \ |
| 35 | + sudo tee /usr/share/keyrings/hhvm.gpg > /dev/null |
| 36 | +
|
| 37 | + # Detect distro |
| 38 | + if command -v lsb_release >/dev/null 2>&1; then |
| 39 | + DISTRO=$(lsb_release -cs) |
| 40 | + else |
| 41 | + DISTRO=$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) |
| 42 | + fi |
| 43 | +
|
| 44 | + echo "Detected distro: $DISTRO" |
28 | 45 |
|
29 | | - DISTRO=$(lsb_release -cs) |
| 46 | + # Add HHVM repo |
30 | 47 | echo "deb [signed-by=/usr/share/keyrings/hhvm.gpg] https://dl.hhvm.com/ubuntu ${DISTRO} main" | \ |
31 | | - sudo tee /etc/apt/sources.list.d/hhvm.list |
| 48 | + sudo tee /etc/apt/sources.list.d/hhvm.list |
| 49 | +
|
32 | 50 | sudo apt-get update |
33 | | - sudo apt-get install -y hhvm |
34 | 51 |
|
| 52 | + INSTALL_SUCCESS=false |
| 53 | +
|
| 54 | + echo "➡️ Trying to install HHVM (stable)..." |
| 55 | + if [ "${{ inputs.hhvm-version }}" = "latest" ]; then |
| 56 | + if sudo apt-get install -y hhvm; then |
| 57 | + INSTALL_SUCCESS=true |
| 58 | + fi |
| 59 | + else |
| 60 | + if sudo apt-get install -y hhvm=${{ inputs.hhvm-version }}; then |
| 61 | + INSTALL_SUCCESS=true |
| 62 | + fi |
| 63 | + fi |
| 64 | +
|
| 65 | + # Fallback to nightly |
| 66 | + if [ "$INSTALL_SUCCESS" = false ]; then |
| 67 | + echo "⚠️ Stable HHVM install failed. Trying hhvm-nightly..." |
| 68 | +
|
| 69 | + sudo apt-get update |
| 70 | + if sudo apt-get install -y hhvm-nightly; then |
| 71 | + INSTALL_SUCCESS=true |
| 72 | + fi |
| 73 | + fi |
| 74 | +
|
| 75 | + # Final failure check |
| 76 | + if [ "$INSTALL_SUCCESS" = false ]; then |
| 77 | + echo "❌ Both hhvm and hhvm-nightly installation failed" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | +
|
| 81 | + # Verify installation |
35 | 82 | hhvm --version |
| 83 | +
|
| 84 | + # Runtime test |
| 85 | + echo '<?hh echo "Hack runtime OK\n";' > test.hack |
| 86 | + hhvm test.hack |
0 commit comments