]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_binaries.yml
Generate binaries for more advanced architectures
[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 12 Apple Clang
27             os: macos-12
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-64
46           - x86-64-modern
47           - x86-64-avx2
48           - x86-64-bmi2
49           # - x86-64-avxvnni needs more recent gcc
50           - x86-64-avx512
51           - x86-64-vnni256
52           - x86-64-vnni512
53         exclude:
54           - binaries: x86-64-bmi2
55             config: { os: macos-12 }
56           #- binaries: x86-64-avxvnni
57           #  config: { os: macos-12 }
58           - binaries: x86-64-avx512
59             config: { os: macos-12 }
60           - binaries: x86-64-vnni256
61             config: { os: macos-12 }
62           - binaries: x86-64-vnni512
63             config: { os: macos-12 }
64     defaults:
65       run:
66         working-directory: src
67         shell: ${{ matrix.config.shell }}
68     steps:
69       - uses: actions/checkout@v3
70         with:
71           fetch-depth: 0
72
73       - name: Download required linux packages
74         if: runner.os == 'Linux'
75         run: sudo apt update
76
77       - name: Setup msys and install required packages
78         if: runner.os == 'Windows'
79         uses: msys2/setup-msys2@v2
80         with:
81           msystem: ${{ matrix.config.msys_sys }}
82           install: mingw-w64-${{ matrix.config.msys_env }} make git zip
83
84       - name: Download SDE package
85         if: runner.os == 'Linux' || runner.os == 'Windows'
86         uses: petarpetrovt/setup-sde@v2.1
87         with:
88           environmentVariableName: SDE_DIR
89           sdeVersion: 9.14.0
90
91       - name: Download the used network from the fishtest framework
92         run: make net
93
94       - name: Check compiler
95         run: $COMPILER -v
96
97       - name: Test help target
98         run: make help
99
100       - name: Check git
101         run: git --version
102
103       # Compile profile guided builds
104
105       - name: Compile ${{ matrix.binaries }} build
106         run: |
107           make -j2 profile-build ARCH=$BINARY COMP=$COMP SDE_PATH="$SDE"
108           make strip ARCH=$BINARY COMP=$COMP
109           mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT
110
111       - name: Remove non src files
112         run: git clean -fx
113
114       - name: Download wiki
115         run: |
116           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
117           rm -rf ../wiki/.git
118
119       - name: Create directory.
120         run: |
121           cd ..
122           mkdir stockfish
123           cp -r wiki stockfish/
124           cp -r src stockfish/
125           cp stockfish-$NAME-$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
132       - name: Create tar
133         if: runner.os != 'Windows'
134         run: |
135           cd ..
136           tar -cvf stockfish-$NAME-$BINARY.tar stockfish
137
138       - name: Create zip
139         if: runner.os == 'Windows'
140         run: |
141           cd ..
142           zip -r stockfish-$NAME-$BINARY.zip stockfish
143
144       - name: Upload binaries
145         if: runner.os != 'Windows'
146         uses: actions/upload-artifact@v3
147         with:
148           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
149           path: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.tar
150
151       # Artifacts automatically get zipped
152       # to avoid double zipping, we use the unzipped directory
153       - name: Upload binaries
154         if: runner.os == 'Windows'
155         uses: actions/upload-artifact@v3
156         with:
157           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
158           path: stockfish
159
160       - name: Release
161         if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
162         uses: softprops/action-gh-release@v1
163         with:
164           files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
165
166       - name: Get last commit sha
167         id: last_commit
168         run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
169
170       - name: Get commit date
171         id: commit_date
172         run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
173
174       # Make sure that an old ci which still runs on master doesn't recreate a prerelease
175       - name: Check Pullable Commits
176         id: check_commits
177         run: |
178           git fetch
179           CHANGES=$(git rev-list HEAD..origin/master --count)
180           echo "CHANGES=$CHANGES" >> $GITHUB_ENV
181
182       - name: Prerelease
183         if: github.ref_name == 'master' && env.CHANGES == '0'
184         continue-on-error: true
185         uses: softprops/action-gh-release@v1
186         with:
187           name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
188           tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
189           prerelease: true
190           files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}