summary refs log tree commit diff
path: root/.github/workflows/build_linux.yml
blob: 04e98b679fda0239f1b9bf856dd696cf4978ac33 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build latest (Linux)
# trigger via either push to selected branches or on manual run
on:
  push:
    branches:
      - main
      - master
      - ModernLighting
  workflow_dispatch:

concurrency:
  group: ${{ github.ref }}-linux
  cancel-in-progress: true

jobs:
#============================================
# =============== 32 BIT LINUX ==============
# ===========================================
  build-32:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v4
      - name: Install packages
        shell: bash
        run: |
          sudo dpkg --add-architecture i386
          sudo apt-get -y update
          sudo apt-get -y install gcc-multilib libx11-dev:i386 libxi-dev:i386 libgl1-mesa-dev:i386
      - name: Compile 32 bit Linux builds
        shell: bash
        id: compile
        env: 
          COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn"
          NIX32_FLAGS:  "-no-pie -fno-pie -m32 -fvisibility=hidden -fcf-protection=none -rdynamic -DCC_BUILD_ICON"
        run: |
          LATEST_FLAG=-DCC_COMMIT_SHA=\"$(git rev-parse --short "$GITHUB_SHA")\"
          
          cd src
          gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.NIX32_FLAGS }} $LATEST_FLAG -o cc-nix32-gl1 -lX11 -lXi -lpthread -lGL -lm -ldl
          gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.NIX32_FLAGS }} $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -o cc-nix32-gl2 -lX11 -lXi -lpthread -lGL -lm -ldl


      - uses: ./.github/actions/notify_failure
        if: ${{ always() && steps.compile.outcome == 'failure' }}
        with:
          NOTIFY_MESSAGE: 'Failed to compile 32 bit Linux build'
          WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}'
      
      
      - uses: ./.github/actions/upload_build
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          SOURCE_FILE: 'src/cc-nix32-gl1'
          DEST_NAME: 'ClassiCube-Linux32-OpenGL'
          
      - uses: ./.github/actions/upload_build
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          SOURCE_FILE: 'src/cc-nix32-gl2'
          DEST_NAME: 'ClassiCube-Linux32-ModernGL'
          
          
      - uses: ./.github/actions/notify_success
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          DESTINATION_URL: '${{ secrets.NOTIFY_URL }}'
          WORKFLOW_NAME: 'linux32'

#============================================
# =============== 64 BIT LINUX ==============
# ===========================================
  build-64:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v4
      - name: Compile 64 bit Linux builds
        shell: bash
        id: compile
        env: 
          COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn"
          NIX64_FLAGS:  "-no-pie -fno-pie -m64 -fvisibility=hidden -fcf-protection=none -rdynamic -DCC_BUILD_ICON"
        run: |
          sudo apt-get -y install libx11-dev libxi-dev libgl1-mesa-dev libsdl2-dev
          LATEST_FLAG=-DCC_COMMIT_SHA=\"$(git rev-parse --short "$GITHUB_SHA")\"  
          
          cd src
          gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.NIX64_FLAGS }} $LATEST_FLAG -o cc-nix64-gl1 -lX11 -lXi -lpthread -lGL -lm -ldl
          gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.NIX64_FLAGS }} $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -o cc-nix64-gl2 -lX11 -lXi -lpthread -lGL -lm -ldl
          gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.NIX64_FLAGS }} $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -DCC_WIN_BACKEND=CC_WIN_BACKEND_SDL2 -o cc-sdl64-gl2 -lSDL2 -lpthread -lGL -lm -ldl


      - uses: ./.github/actions/notify_failure
        if: ${{ always() && steps.compile.outcome == 'failure' }}
        with:
          NOTIFY_MESSAGE: 'Failed to compile 64 bit Linux build'
          WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}'
          
          
      - uses: ./.github/actions/upload_build
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          SOURCE_FILE: 'src/cc-nix64-gl1'
          DEST_NAME: 'ClassiCube-Linux64-OpenGL'
          
      - uses: ./.github/actions/upload_build
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          SOURCE_FILE: 'src/cc-nix64-gl2'
          DEST_NAME: 'ClassiCube-Linux64-ModernGL'
          
      - uses: ./.github/actions/upload_build
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          SOURCE_FILE: 'src/cc-sdl64-gl2'
          DEST_NAME: 'ClassiCube-Linux64-SDL2'
          
          
      - uses: ./.github/actions/notify_success
        if: ${{ always() && steps.compile.outcome == 'success' }}
        with:
          DESTINATION_URL: '${{ secrets.NOTIFY_URL }}'
          WORKFLOW_NAME: 'linux64'