aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/build.yml
blob: d702849b310cf60de67d01d3a4aafb2adb5b8c4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Build and Test

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y lua5.4 liblua5.4-dev

      - name: Install Premake
        run: |
          PREMAKE_VERSION="5.0.0-beta2"
          OS="linux"
          wget -q https://github.com/premake/premake-core/releases/download/v${PREMAKE_VERSION}/premake-${PREMAKE_VERSION}-${OS}.tar.gz -O premake.tar.gz
          tar -xzf premake.tar.gz
          sudo mv premake5 /usr/bin
          sudo chmod +x /usr/bin/premake5
          rm premake.tar.gz

      - name: Generate Makefile with Premake
        run: premake5 gmake

      - name: Build project
        run: make

      - name: Install shell program
        run: |
          if [ ! -d ~/.lush ]; then
            cp -rf ./.lush ~/
          fi

          sudo cp ./bin/Debug/lush/lush /usr/bin/lush.new
          sudo mv /usr/bin/lush.new /usr/bin/lush
          
          # Ensure the shell is registered in /etc/shells
          if ! grep -Fxq "/usr/bin/lush" /etc/shells; then
            echo "/usr/bin/lush" | sudo tee -a /etc/shells >/dev/null
          fi  

      - name: Run Lua tests
        run: lush ./test/run_tests.lua

      - name: Upload the compiled binary (Optional)
        uses: actions/upload-artifact@v3
        with:
          name: lush-binary
          path: ./bin/Debug/lush/lush