]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_arm_binaries.yml
Fix compilation after recent merge.
[stockfish] / .github / workflows / stockfish_arm_binaries.yml
1 name: Stockfish
2 on:
3   workflow_call:
4 jobs:
5   Stockfish:
6     name: ${{ matrix.config.name }} ${{ matrix.binaries }}
7     runs-on: ${{ matrix.config.os }}
8     env:
9       COMPILER: ${{ matrix.config.compiler }}
10       COMP: ${{ matrix.config.comp }}
11       EMU: ${{ matrix.config.emu }}
12       EXT: ${{ matrix.config.ext }}
13       OS: ${{ matrix.config.os }}
14       BINARY: ${{ matrix.binaries }}
15     strategy:
16       matrix:
17         config:
18           - name: Android NDK aarch64
19             os: ubuntu-22.04
20             compiler: aarch64-linux-android21-clang++
21             emu: qemu-aarch64
22             comp: ndk
23             shell: bash
24           - name: Android NDK arm
25             os: ubuntu-22.04
26             compiler: armv7a-linux-androideabi21-clang++
27             emu: qemu-arm
28             comp: ndk
29             shell: bash
30         binaries:
31           - armv8-dotprod
32           - armv8
33           - armv7
34           - armv7-neon
35         exclude:
36           - binaries: armv8-dotprod
37             config: {compiler: armv7a-linux-androideabi21-clang++}
38           - binaries: armv8
39             config: {compiler: armv7a-linux-androideabi21-clang++}
40           - binaries: armv7
41             config: {compiler: aarch64-linux-android21-clang++}
42           - binaries: armv7-neon
43             config: {compiler: aarch64-linux-android21-clang++}
44     defaults:
45       run:
46         working-directory: src
47         shell: ${{ matrix.config.shell }}
48     steps:
49       - uses: actions/checkout@v4
50         with:
51           fetch-depth: 0
52
53       - name: Download required linux packages
54         if: runner.os == 'Linux'
55         run: |
56           sudo apt update
57           sudo apt install qemu-user
58
59       - name: Install NDK
60         if: runner.os == 'Linux'
61         run: |
62           if [ $COMP == ndk ]; then
63             NDKV="21.4.7075529"
64             ANDROID_ROOT=/usr/local/lib/android
65             ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
66             SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
67             echo "y" | $SDKMANAGER "ndk;$NDKV"
68             ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDKV
69             ANDROID_NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
70             echo "ANDROID_NDK_BIN=$ANDROID_NDK_BIN" >> $GITHUB_ENV
71           fi
72
73       - name: Extract the bench number from the commit history
74         run: |
75           for hash in $(git rev-list -100 HEAD); do
76             benchref=$(git show -s $hash | tac | grep -m 1 -o -x '[[:space:]]*\b[Bb]ench[ :]\+[1-9][0-9]\{5,7\}\b[[:space:]]*' | sed 's/[^0-9]//g') && break || true
77           done
78           [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $hash" && echo "Reference bench: $benchref" || echo "No bench found"
79
80       - name: Download the used network from the fishtest framework
81         run: make net
82
83       - name: Check compiler
84         run: |
85           if [ $COMP == ndk ]; then
86             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
87           fi
88           $COMPILER -v
89
90       - name: Test help target
91         run: make help
92
93       - name: Check git
94         run: git --version
95
96       # Compile profile guided builds
97
98       - name: Compile ${{ matrix.binaries }} build
99         run: |
100           if [ $COMP == ndk ]; then
101             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
102             export LDFLAGS="-static -Wno-unused-command-line-argument"
103           fi
104           make clean
105           make -j2 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH=$EMU
106           make strip ARCH=$BINARY COMP=$COMP
107           WINE_PATH=$EMU ../tests/signature.sh $benchref
108           mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT
109
110       - name: Remove non src files
111         run: rm -f *.o .depend *.nnue
112
113       - name: Download wiki
114         run: |
115           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
116           cd ../wiki
117           rm -rf .git
118
119       - name: Create tar archive.
120         run: |
121           cd ..
122           mkdir stockfish
123           cp -r wiki stockfish/
124           cp -r src stockfish/
125           cp stockfish-android-$BINARY$EXT stockfish/
126           cp "Top CPU Contributors.txt" stockfish/
127           cp Copying.txt stockfish/
128           cp AUTHORS stockfish/
129           cp CITATION.cff stockfish/
130           cp README.md stockfish/
131           cp CONTRIBUTING.md stockfish/
132           tar -cvf stockfish-android-$BINARY.tar stockfish
133
134       - name: Upload binaries
135         uses: actions/upload-artifact@v3
136         with:
137           name: stockfish-android-${{ matrix.binaries }}
138           path: stockfish-android-${{ matrix.binaries }}.tar
139
140       - name: Release
141         if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
142         uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844  # @v1
143         with:
144           files: stockfish-android-${{ matrix.binaries }}.tar
145
146       - name: Get last commit sha
147         id: last_commit
148         run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
149
150       - name: Get commit date
151         id: commit_date
152         run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
153
154       # Make sure that an old ci which still runs on master doesn't recreate a prerelease
155       - name: Check Pullable Commits
156         id: check_commits
157         run: |
158           git fetch
159           CHANGES=$(git rev-list HEAD..origin/master --count)
160           echo "CHANGES=$CHANGES" >> $GITHUB_ENV
161
162       - name: Prerelease
163         if: github.ref_name == 'master' && env.CHANGES == '0'
164         continue-on-error: true
165         uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844  # @v1
166         with:
167           name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
168           tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
169           prerelease: true
170           files: stockfish-android-${{ matrix.binaries }}.tar