]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_binaries.yml
f7669b479aa4f7629a3bb33f7ef849c3907561c1
[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       NAME: ${{ matrix.config.simple_name }}
13       BINARY: ${{ matrix.binaries }}
14     strategy:
15       matrix:
16         config:
17           - name: Ubuntu 20.04 GCC
18             os: ubuntu-20.04
19             simple_name: ubuntu
20             compiler: g++
21             comp: gcc
22             shell: bash
23             archive_ext: tar
24           - name: MacOS 12 Apple Clang
25             os: macos-12
26             simple_name: macos
27             compiler: clang++
28             comp: clang
29             shell: bash
30             archive_ext: tar
31           - name: Windows 2022 Mingw-w64 GCC x86_64
32             os: windows-2022
33             simple_name: windows
34             compiler: g++
35             comp: mingw
36             msys_sys: mingw64
37             msys_env: x86_64-gcc
38             shell: msys2 {0}
39             ext: .exe
40             archive_ext: zip
41         binaries:
42           - x86-64
43           - x86-64-modern
44           - x86-64-avx2
45           - x86-64-bmi2
46         exclude:
47           - binaries: x86-64-avx2
48             config: { os: macos-12 }
49           - binaries: x86-64-bmi2
50             config: { os: macos-12 }
51     defaults:
52       run:
53         working-directory: src
54         shell: ${{ matrix.config.shell }}
55     steps:
56       - uses: actions/checkout@v3
57         with:
58           fetch-depth: 0
59
60       - name: Download required linux packages
61         if: runner.os == 'Linux'
62         run: sudo apt update
63
64       - name: Setup msys and install required packages
65         if: runner.os == 'Windows'
66         uses: msys2/setup-msys2@v2
67         with:
68           msystem: ${{ matrix.config.msys_sys }}
69           install: mingw-w64-${{ matrix.config.msys_env }} make git zip
70
71       - name: Download the used network from the fishtest framework
72         run: make net
73
74       - name: Check compiler
75         run: $COMPILER -v
76
77       - name: Test help target
78         run: make help
79
80       - name: Check git
81         run: git --version
82
83       # Compile profile guided builds
84
85       - name: Compile ${{ matrix.binaries }} build
86         run: |
87           make -j2 profile-build ARCH=$BINARY COMP=$COMP
88           make strip ARCH=$BINARY COMP=$COMP
89           mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT
90
91       - name: Remove non src files
92         run: git clean -fx
93
94       - name: Download wiki
95         run: |
96           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
97           rm -rf ../wiki/.git
98
99       - name: Create directory.
100         run: |
101           cd ..
102           mkdir stockfish
103           cp -r wiki stockfish/
104           cp -r src stockfish/
105           cp stockfish-$NAME-$BINARY$EXT stockfish/
106           cp "Top CPU Contributors.txt" stockfish/
107           cp Copying.txt stockfish/
108           cp AUTHORS stockfish/
109           cp CITATION.cff stockfish/
110           cp README.md stockfish/
111
112       - name: Create tar
113         if: runner.os != 'Windows'
114         run: |
115           cd ..
116           tar -cvf stockfish-$NAME-$BINARY.tar stockfish
117
118       - name: Create zip
119         if: runner.os == 'Windows'
120         run: |
121           cd ..
122           zip -r stockfish-$NAME-$BINARY.zip stockfish
123
124       - name: Upload binaries
125         if: runner.os != 'Windows'
126         uses: actions/upload-artifact@v3
127         with:
128           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
129           path: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.tar
130
131       # Artifacts automatically get zipped
132       # to avoid double zipping, we use the unzipped directory
133       - name: Upload binaries
134         if: runner.os == 'Windows'
135         uses: actions/upload-artifact@v3
136         with:
137           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
138           path: stockfish
139
140       - name: Release
141         if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
142         uses: softprops/action-gh-release@v1
143         with:
144           files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
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@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-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}