]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_binaries.yml
Fix compilation after recent merge.
[stockfish] / .github / workflows / stockfish_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       EXT: ${{ matrix.config.ext }}
12       SDE: ${{ matrix.config.sde }}
13       NAME: ${{ matrix.config.simple_name }}
14       BINARY: ${{ matrix.binaries }}
15     strategy:
16       fail-fast: false
17       matrix:
18         config:
19           - name: Ubuntu 20.04 GCC
20             os: ubuntu-20.04
21             simple_name: ubuntu
22             compiler: g++
23             comp: gcc
24             shell: bash
25             archive_ext: tar
26             sde: /home/runner/work/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-lin/sde -future --
27           - name: MacOS 13 Apple Clang
28             os: macos-13
29             simple_name: macos
30             compiler: clang++
31             comp: clang
32             shell: bash
33             archive_ext: tar
34           - name: Windows 2022 Mingw-w64 GCC x86_64
35             os: windows-2022
36             simple_name: windows
37             compiler: g++
38             comp: mingw
39             msys_sys: mingw64
40             msys_env: x86_64-gcc
41             shell: msys2 {0}
42             ext: .exe
43             sde: /d/a/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-win/sde.exe -future --
44             archive_ext: zip
45         binaries:
46           - x86-64
47           - x86-64-sse41-popcnt
48           - x86-64-avx2
49           - x86-64-bmi2
50           - x86-64-avxvnni
51           - x86-64-avx512
52           - x86-64-vnni256
53           - x86-64-vnni512
54         exclude:
55           - binaries: x86-64-avxvnni
56             config: { ubuntu-20.04 }
57           - binaries: x86-64-avxvnni
58             config: { os: macos-13 }
59           - binaries: x86-64-avx512
60             config: { os: macos-13 }
61           - binaries: x86-64-vnni256
62             config: { os: macos-13 }
63           - binaries: x86-64-vnni512
64             config: { os: macos-13 }
65     defaults:
66       run:
67         working-directory: src
68         shell: ${{ matrix.config.shell }}
69     steps:
70       - uses: actions/checkout@v4
71         with:
72           fetch-depth: 0
73
74       - name: Download required macOS packages
75         if: runner.os == 'macOS'
76         run: brew install coreutils
77
78       - name: Install fixed GCC on Linux
79         if: runner.os == 'Linux'
80         uses: egor-tensin/setup-gcc@eaa888eb19115a521fa72b65cd94fe1f25bbcaac  # @v1.3
81         with:
82           version: 11
83
84       - name: Setup msys and install required packages
85         if: runner.os == 'Windows'
86         uses: msys2/setup-msys2@v2
87         with:
88           msystem: ${{ matrix.config.msys_sys }}
89           install: mingw-w64-${{ matrix.config.msys_env }} make git zip
90
91       - name: Download SDE package
92         if: runner.os == 'Linux' || runner.os == 'Windows'
93         uses: petarpetrovt/setup-sde@91a1a03434384e064706634125a15f7446d2aafb  # @v2.3
94         with:
95           environmentVariableName: SDE_DIR
96           sdeVersion: 9.27.0
97
98       - name: Download the used network from the fishtest framework
99         run: make net
100
101       - name: Extract the bench number from the commit history
102         run: |
103           for hash in $(git rev-list -100 HEAD); do
104             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
105           done
106           [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $hash" && echo "Reference bench: $benchref" || echo "No bench found"
107
108       - name: Check compiler
109         run: $COMPILER -v
110
111       - name: Show g++ cpu info
112         if: runner.os != 'macOS'
113         run: g++ -Q -march=native --help=target
114
115       - name: Show clang++ cpu info
116         if: runner.os == 'macOS'
117         run: clang++ -E - -march=native -###
118
119       - name: Test help target
120         run: make help
121
122       - name: Check git
123         run: git --version
124
125       # Compile profile guided builds
126
127       - name: Compile ${{ matrix.binaries }} build
128         run: |
129           make -j2 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH="$SDE"
130           make strip ARCH=$BINARY COMP=$COMP
131           WINE_PATH="$SDE" ../tests/signature.sh $benchref
132           mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT
133
134       - name: Remove non src files
135         run: git clean -fx
136
137       - name: Download wiki
138         run: |
139           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
140           rm -rf ../wiki/.git
141
142       - name: Create directory.
143         run: |
144           cd ..
145           mkdir stockfish
146           cp -r wiki stockfish/
147           cp -r src stockfish/
148           cp stockfish-$NAME-$BINARY$EXT stockfish/
149           cp "Top CPU Contributors.txt" stockfish/
150           cp Copying.txt stockfish/
151           cp AUTHORS stockfish/
152           cp CITATION.cff stockfish/
153           cp README.md stockfish/
154           cp CONTRIBUTING.md stockfish/
155
156       - name: Create tar
157         if: runner.os != 'Windows'
158         run: |
159           cd ..
160           tar -cvf stockfish-$NAME-$BINARY.tar stockfish
161
162       - name: Create zip
163         if: runner.os == 'Windows'
164         run: |
165           cd ..
166           zip -r stockfish-$NAME-$BINARY.zip stockfish
167
168       - name: Upload binaries
169         if: runner.os != 'Windows'
170         uses: actions/upload-artifact@v3
171         with:
172           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
173           path: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.tar
174
175       # Artifacts automatically get zipped
176       # to avoid double zipping, we use the unzipped directory
177       - name: Upload binaries
178         if: runner.os == 'Windows'
179         uses: actions/upload-artifact@v3
180         with:
181           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
182           path: stockfish
183
184       - name: Release
185         if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
186         uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844  # @v1
187         with:
188           files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
189
190       - name: Get last commit sha
191         id: last_commit
192         run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
193
194       - name: Get commit date
195         id: commit_date
196         run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
197
198       # Make sure that an old ci which still runs on master doesn't recreate a prerelease
199       - name: Check Pullable Commits
200         id: check_commits
201         run: |
202           git fetch
203           CHANGES=$(git rev-list HEAD..origin/master --count)
204           echo "CHANGES=$CHANGES" >> $GITHUB_ENV
205
206       - name: Prerelease
207         if: github.ref_name == 'master' && env.CHANGES == '0'
208         continue-on-error: true
209         uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844  # @v1
210         with:
211           name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
212           tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
213           prerelease: true
214           files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}