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