]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_arm_binaries.yml
4db216eb5fb65049d5812c5772ccd51964c9344e
[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@v3
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: Download the used network from the fishtest framework
74         run: make net
75
76       - name: Check compiler
77         run: |
78           if [ $COMP == ndk ]; then
79             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
80           fi
81           $COMPILER -v
82
83       - name: Test help target
84         run: make help
85
86       - name: Check git
87         run: git --version
88
89       # Compile profile guided builds
90
91       - name: Compile ${{ matrix.binaries }} build
92         run: |
93           if [ $COMP == ndk ]; then
94             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
95             export LDFLAGS="-static -Wno-unused-command-line-argument"
96           fi
97           make clean
98           make -j2 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH=$EMU
99           make strip ARCH=$BINARY COMP=$COMP
100           mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT
101
102       - name: Remove non src files
103         run: rm -f *.o .depend *.nnue
104
105       - name: Download wiki
106         run: |
107           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
108           cd ../wiki
109           rm -rf .git
110
111       - name: Create tar archive.
112         run: |
113           cd ..
114           mkdir stockfish
115           cp -r wiki stockfish/
116           cp -r src stockfish/
117           cp stockfish-android-$BINARY$EXT stockfish/
118           cp "Top CPU Contributors.txt" stockfish/
119           cp Copying.txt stockfish/
120           cp AUTHORS stockfish/
121           cp CITATION.cff stockfish/
122           cp README.md stockfish/
123           tar -cvf stockfish-android-$BINARY.tar stockfish
124
125       - name: Upload binaries
126         uses: actions/upload-artifact@v3
127         with:
128           name: stockfish-android-${{ matrix.binaries }}
129           path: stockfish-android-${{ matrix.binaries }}.tar
130
131       - name: Release
132         if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
133         uses: softprops/action-gh-release@v1
134         with:
135           files: stockfish-android-${{ matrix.binaries }}.tar
136
137       - name: Get last commit sha
138         id: last_commit
139         run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
140
141       - name: Get commit date
142         id: commit_date
143         run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
144
145       # Make sure that an old ci which still runs on master doesn't recreate a prerelease
146       - name: Check Pullable Commits
147         id: check_commits
148         run: |
149           git fetch
150           CHANGES=$(git rev-list HEAD..origin/master --count)
151           echo "CHANGES=$CHANGES" >> $GITHUB_ENV
152
153       - name: Prerelease
154         if: github.ref_name == 'master' && env.CHANGES == '0'
155         continue-on-error: true
156         uses: softprops/action-gh-release@v1
157         with:
158           name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
159           tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
160           prerelease: true
161           files: stockfish-android-${{ matrix.binaries }}.tar