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