summaryrefslogtreecommitdiff
path: root/.github/workflows/build_release.yml
blob: 2ab57870188ebed0366add392a980a3b0b754bc4 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: 🔧 Build -> Package 📦
on: [push, pull_request]

jobs:
  static-checks:
    name: 📊 Static Checks (clang-format, black format, file format)
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install dependencies
        run: |
          sudo apt-get install -qq dos2unix recode clang-format-11
          sudo update-alternatives --remove-all clang-format
          sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
          sudo pip3 install black==20.8b1 pygments

      - name: File formatting checks (file_format.sh)
        run: |
          bash ./misc/scripts/file_format.sh

      - name: Style checks via clang-format (clang_format.sh)
        run: |
          bash ./misc/scripts/clang_format.sh

      - name: Python style checks via black (black_format.sh)
        run: |
          bash ./misc/scripts/black_format.sh

  build:
    runs-on: ${{ matrix.os }}
    name: 🔧 Build
    needs: static-checks
    strategy:
      matrix:
        include:
          # Android
          - platform: android
            arch: 'x86'
            sconsflags: 'android_arch=x86'
            os: 'ubuntu-20.04'
          - platform: android
            arch: 'x64'
            sconsflags: 'android_arch=x86_64'
            os: 'ubuntu-20.04'
          - platform: android
            arch: 'arm'
            sconsflags: 'android_arch=armv7'
            os: 'ubuntu-20.04'
          - platform: android
            arch: 'arm64'
            sconsflags: 'android_arch=arm64v8'
            os: 'ubuntu-20.04'

          # iOS
          - platform: ios
            arch: 'x64'
            sconsflags: 'ios_arch=x86_64 ios_simulator=true'
            os: 'macos-latest'
          - platform: ios
            arch: 'arm'
            sconsflags: 'ios_arch=armv7'
            os: 'macos-latest'
          - platform: ios
            arch: 'arm64'
            sconsflags: 'ios_arch=arm64'
            os: 'macos-latest'

          # Linux
          - platform: linux
            arch: 'x86'
            sconsflags: 'bits=32'
            os: 'ubuntu-20.04'
          - platform: linux
            arch: 'x64'
            sconsflags: 'bits=64'
            os: 'ubuntu-20.04'

          # macOS
          - platform: osx
            arch: 'x64'
            sconsflags: 'bits=64'
            os: 'macos-latest'
          - platform: osx
            arch: 'arm64'
            sconsflags: 'bits=64 macos_arch=arm64 macos_sdk_path=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/'
            os: 'macos-10.15'

          # Windows
          - platform: windows
            arch: 'x86'
            sconsflags: 'bits=32'
            os: 'windows-latest'
            msvc_arch: amd64_x86
          - platform: windows
            arch: 'x64'
            sconsflags: 'bits=64'
            os: 'windows-latest'
            msvc_arch: amd64

    env:
      SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} --jobs=2
      NDK_VERSION: 22b
      ANDROID_NDK_ROOT: ${{github.workspace}}/android-ndk-r22b
      MSVC_VARS: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'

    defaults:
      run:
        shell: bash

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive

      - name: Cache NDK
        id: cache-ndk
        if: ${{ matrix.platform == 'android' }}
        uses: actions/cache@v2
        with:
          path: ${{ env.ANDROID_NDK_ROOT }}
          key: ndk-${{ env.NDK_VERSION }}

      - name: Download NDK
        if: ${{ matrix.platform == 'android' && steps.cache-ndk.outputs.cache-hit != 'true' }}
        id: setup-ndk
        run: |
          cd ${{ github.workspace }}
          curl -L https://dl.google.com/android/repository/android-ndk-r${{ env.NDK_VERSION }}-linux-x86_64.zip -o ndk.zip
          unzip ndk.zip
          ls

      - name: Setup MSVC build environment for ${{ matrix.msvc_arch }}
        if: ${{ matrix.platform == 'windows' }}
        run: "'${{ env.MSVC_VARS }}' ${{ matrix.msvc_arch }}"

      - name: Install Linux build dependencies
        if: ${{ matrix.platform == 'linux' }}
        run: |
          sudo apt-get install build-essential gcc-multilib wget g++-multilib

      - name: Set up Python 3.x
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'
          architecture: 'x64'

      - name: Configuring Python packages
        run: |
          python -c "import sys; print(sys.version)"
          python -m pip install scons
          python --version
          scons --version

      - name: Get WebRTC package for ${{ matrix.platform }} - ${{ matrix.arch }}
        uses: ./.github/actions/webrtc-download
        with:
          platform: ${{ matrix.platform }}
          archs: ${{ matrix.arch }}

      - name: Fix godot-cpp revision and file names for OSX arm64 build.
        if: ${{ matrix.platform == 'osx' && matrix.arch == 'arm64' }}
        run: |
          cd godot-cpp
          git checkout e08ecdc28c5409cb5366027227e996c342dcee93
          rm -rf src/gen/
          rm -rf include/gen/
          mkdir bin
          ln -s libgodot-cpp.osx.debug.64.a bin/libgodot-cpp.osx.debug.arm64.a
          ln -s libgodot-cpp.osx.release.64.a bin/libgodot-cpp.osx.release.arm64.a

      - name: Compilation ${{ matrix.platform }} - ${{ matrix.arch }} - godot-cpp
        run: |
          scons -C godot-cpp target=debug generate_bindings=yes
          scons -C godot-cpp target=release

      - name: Compilation ${{ matrix.platform }} - ${{ matrix.arch }} - webrtc-native
        run: |
          scons target=debug
          scons target=release

      - uses: actions/upload-artifact@v2
        with:
          name: ${{ github.job }}-${{ matrix.platform }}-${{ matrix.arch }}
          path: bin/*

  package:
    name: 📦 Package
    needs: build
    runs-on: "ubuntu-latest"
    steps:
      - uses: actions/checkout@v2

      - uses: actions/download-artifact@v2
        with:
          path: artifacts

      - name: Package artifacts for release
        run: |
          mkdir release
          cd release
          for name in webrtc webrtc_debug
          do
            mkdir -p ${name}/lib/
            find ../artifacts -wholename "*/${name}/lib/*" | xargs cp -t ${name}/lib/
            find ../artifacts -wholename "*/${name}/${name}.tres" | head -n 1 | xargs cp -t ${name}/
          done

          zip -r godot-webrtc-native-release.zip webrtc
          zip -r godot-webrtc-native-debug.zip webrtc_debug
          ls -R

      - uses: actions/upload-artifact@v2
        with:
          name: godot-webrtc-native-debug.zip
          path: release/godot-webrtc-native-debug.zip

      - uses: actions/upload-artifact@v2
        with:
          name: godot-webrtc-native-release.zip
          path: release/godot-webrtc-native-release.zip