]> git.sesse.net Git - stockfish/blobdiff - .github/workflows/stockfish_binaries.yml
create prereleases upon push to master
[stockfish] / .github / workflows / stockfish_binaries.yml
index b22897cf69215ba7bd3c673382ffc8343cfbfe59..0a53cb03a99bb4b988cbd8c25a1dd2a8168aeae2 100644 (file)
@@ -9,29 +9,35 @@ jobs:
       COMPILER: ${{ matrix.config.compiler }}
       COMP: ${{ matrix.config.comp }}
       EXT: ${{ matrix.config.ext }}
-      OS: ${{ matrix.config.os }}
+      NAME: ${{ matrix.config.simple_name }}
       BINARY: ${{ matrix.binaries }}
     strategy:
       matrix:
         config:
           - name: Ubuntu 20.04 GCC
             os: ubuntu-20.04
+            simple_name: ubuntu
             compiler: g++
             comp: gcc
             shell: bash {0}
+            archive_ext: tar
           - name: MacOS 12 Apple Clang
             os: macos-12
+            simple_name: macos
             compiler: clang++
             comp: clang
             shell: bash {0}
+            archive_ext: tar
           - name: Windows 2022 Mingw-w64 GCC x86_64
             os: windows-2022
+            simple_name: windows
             compiler: g++
             comp: mingw
             msys_sys: mingw64
             msys_env: x86_64-gcc
             shell: msys2 {0}
             ext: .exe
+            archive_ext: zip
         binaries:
           - x86-64
           - x86-64-modern
@@ -57,7 +63,7 @@ jobs:
         uses: msys2/setup-msys2@v2
         with:
           msystem: ${{ matrix.config.msys_sys }}
-          install: mingw-w64-${{ matrix.config.msys_env }} make git
+          install: mingw-w64-${{ matrix.config.msys_env }} make git zip
 
       - name: Download the used network from the fishtest framework
         run: make net
@@ -75,34 +81,88 @@ jobs:
 
       - name: Compile ${{ matrix.binaries }} build
         run: |
-          make clean
           make -j2 profile-build ARCH=$BINARY COMP=$COMP
           make strip ARCH=$BINARY COMP=$COMP
-          mv ./stockfish$EXT ../stockfish-$OS-$BINARY$EXT
+          mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT
 
       - name: Remove non src files
-        run: rm -f *.o .depend *.nnue
+        run: git clean -fx
 
       - name: Download wiki
         run: |
           git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki
-          cd ../wiki
-          rm -rf .git
+          rm -rf ../wiki/.git
 
-      - name: Create tar archive.
+      - name: Create directory.
         run: |
           cd ..
           mkdir stockfish
           cp -r wiki stockfish/
           cp -r src stockfish/
-          cp stockfish-$OS-$BINARY$EXT stockfish/
+          cp stockfish-$NAME-$BINARY$EXT stockfish/
           cp "Top CPU Contributors.txt" stockfish/
           cp Copying.txt stockfish/
           cp AUTHORS stockfish/
-          tar -cvf stockfish-$OS-$BINARY.tar stockfish
+          cp CITATION.cff stockfish/
+          cp README.md stockfish/
 
+      - name: Create tar
+        if: runner.os != 'Windows'
+        run: |
+          cd ..
+          tar -cvf stockfish-$NAME-$BINARY.tar stockfish
+
+      - name: Create zip
+        if: runner.os == 'Windows'
+        run: |
+          cd ..
+          zip -r stockfish-$NAME-$BINARY.zip stockfish
+
+      - name: Upload binaries
+        if: runner.os != 'Windows'
+        uses: actions/upload-artifact@v3
+        with:
+          name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
+          path: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.tar
+
+      # Artifacts automatically get zipped
+      # to avoid double zipping, we use the unzipped directory
       - name: Upload binaries
+        if: runner.os == 'Windows'
         uses: actions/upload-artifact@v3
         with:
           name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}
-          path: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}.tar
+          path: stockfish
+
+      - name: Release
+        if: startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'
+        uses: softprops/action-gh-release@v1
+        with:
+          files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
+
+      - name: Get last commit sha
+        id: last_commit
+        run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
+
+      - name: Get commit date
+        id: commit_date
+        run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
+
+      # Make sure that an old ci which still runs on master doesn't recreate a prerelease
+      - name: Check Pullable Commits
+        id: check_commits
+        run: |
+          git fetch
+          CHANGES=$(git rev-list HEAD..origin/master --count)
+          echo "CHANGES=$CHANGES" >> $GITHUB_ENV
+
+      - name: Prerelease
+        if: github.ref_name == 'master' && env.CHANGES == '0'
+        continue-on-error: true
+        uses: softprops/action-gh-release@v1
+        with:
+          name: Stockfish dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
+          tag_name: stockfish-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
+          prerelease: true
+          files: stockfish-${{ matrix.config.simple_name }}-${{ matrix.binaries }}.${{ matrix.config.archive_ext }}
+