From e81229e6c2b866637cb130b4a49416ecfb42db00 Mon Sep 17 00:00:00 2001 From: mrdcvlsc Date: Fri, 24 May 2024 21:45:31 +0800 Subject: [PATCH] add auto-compilation of executable on workflow --- .github/workflows/build.yml | 62 +++++++++++++++++++++++------- Makefile | 6 +-- dependencies/pgn-extract/Makefile | 4 +- dependencies/uci-analyser/Makefile | 6 +-- 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddbb50f..13bede0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,8 @@ on: jobs: build: + permissions: write-all + name: ${{matrix.platform.name}} runs-on: ${{matrix.platform.os}} @@ -16,28 +18,26 @@ jobs: matrix: platform: - # - { name: Windows VS2019, ls: dir, os: windows-2019, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bin: .\apgn.exe } - # - { name: Windows VS2022, ls: dir, os: windows-2022, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bin: .\apgn.exe } - # - { name: Windows-Clang, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bin: .\apgn.exe, flags: CC=clang CXX=clang++ } - - { name: Windows-GCC, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bin: .\apgn.exe, flags: CC=gcc CXX=g++ } - - { name: Linux-GCC, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn } - - { name: Linux-Clang, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn, flags: CC=clang CXX=clang++ } - # - { name: MacOS-XCode, ls: ls, os: macos-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn } + # - { name: MacOS-XCode, cpyd: cp -R, cpyf: cp, ls: ls, os: macos-latest, zip: mac-apgn.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn } + # - { name: Windows VS2019, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-2019, zip: windows-apgn-VS19.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe } + # - { name: Windows VS2022, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-2022, zip: windows-apgn-VS22.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe } + # - { name: Windows-Clang, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-latest, zip: windows-apgn-clang.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe, flags: CC=clang CXX=clang++ } + - { name: Windows-GCC, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-latest, zip: windows-apgn-gcc.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe, flags: CC=gcc CXX=g++ } + - { name: Linux-GCC, cpyd: cp -r, cpyf: cp, ls: ls, os: ubuntu-latest, zip: ubuntu-apgn-gcc.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn } + - { name: Linux-Clang, cpyd: cp -r, cpyf: cp, ls: ls, os: ubuntu-latest, zip: ubuntu-apgn-clang.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn, flags: CC=clang CXX=clang++ } steps: - uses: actions/checkout@v3 - - run: echo "this is a test" > test.log + - name: Display Tag Name + run : echo ${{github.ref_name}}-${{github.sha}} - name: build for -> ${{matrix.platform.os}} - run: make ${{matrix.platform.flags}} -j4 + run: make ${{matrix.platform.flags}} -j2 - name: ready executable for execution run: chmod a+rx ${{matrix.platform.bin}} - - name: ready first.pgn for reading - run: chmod a+r ${{matrix.platform.testpgn}} - - name: run test run: ${{matrix.platform.bin}} -depth 5 ${{matrix.platform.testpgn}} @@ -54,4 +54,40 @@ jobs: # run: ${{matrix.platform.disp}} ${{matrix.platform.testuci}} - name: display results - run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}} \ No newline at end of file + run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}} + + - name: make a build folder + run: mkdir build + + - name: copy the resources in the build folder + run: ${{matrix.platform.cpyd}} bin ${{matrix.platform.bindest}} + + - name: copy the binary to the build folder + run: ${{matrix.platform.cpyf}} ${{matrix.platform.bin}} build + + - name: display the contents of the build folder + run: cd build && ${{matrix.platform.ls}} + + - name: display the contents of the bin folder + run: cd build && cd bin && ${{matrix.platform.ls}} + + - name: display the contents of the engines folder + run: cd build && cd bin && cd engines && ${{matrix.platform.ls}} + + - name: zip the build folder + run: ${{matrix.platform.zipd}} ${{matrix.platform.zip}} build + + - name: Create github release and upload ${{matrix.platform.zip}} + run: gh release create ${{github.ref_name}}-${{github.sha}} ${{matrix.platform.zip}} --title "${{github.ref_name}}-${{github.sha}}" --notes "Release notes for ${{github.ref_name}}-${{github.sha}}" --draft=false --prerelease=true + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload ${{matrix.platform.zip}} to release + run: gh release upload ${{github.ref_name}}-${{github.sha}} ${{matrix.platform.zip}} + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Done + run: echo Workflow Done \ No newline at end of file diff --git a/Makefile b/Makefile index d907879..708726f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) OS := $(shell uname) CXX=g++ -CXX_FLAGS=-std=c++17 -static-libgcc -static-libstdc++ -O3 +CXX_FLAGS=-static -static-libgcc -static-libstdc++ -std=c++17 -O3 ifeq ($(OS), Linux) EXTENSION= EXECUTABLE=apgn @@ -21,9 +21,9 @@ all: mv dependencies/uci-analyser/analyse bin/analyse ifeq ($(OS), Linux) - chmod +x bin/engines/stockfish + chmod a+rx bin/engines/stockfish else - chmod +x bin/engines/stockfish.exe + chmod a+rx bin/engines/stockfish.exe endif ${CXX} ${CXX_FLAGS} main.cpp -o ${EXECUTABLE} diff --git a/dependencies/pgn-extract/Makefile b/dependencies/pgn-extract/Makefile index f11d8db..3dcd0b5 100644 --- a/dependencies/pgn-extract/Makefile +++ b/dependencies/pgn-extract/Makefile @@ -46,7 +46,7 @@ OPTIMISE=-O3 # $(OPTIMISE) # PRODUCTION -CFLAGS+=-c -I/usr/local/lib/ansi-include -static-libgcc -std=c99 \ +CFLAGS+=-c -I/usr/local/lib/ansi-include -std=c99 \ $(CPPFLAGS) $(OPTIMISE) CC=gcc @@ -58,7 +58,7 @@ AIX_CFLAGS=-c -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_ALL_SOURCE AIX_CC=xlc pgn-extract : $(OBJS) - $(CC) $(DEBUGINFO) $(ORIGCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o pgn-extract + $(CC) -static -static-libgcc -std=c99 -O3 $(LDFLAGS) $(OBJS) $(LIBS) -o pgn-extract purify : $(OBJS) purify $(CC) $(DEBUGINFO) $(OBJS) -o pgn-extract diff --git a/dependencies/uci-analyser/Makefile b/dependencies/uci-analyser/Makefile index b5b4296..db02713 100755 --- a/dependencies/uci-analyser/Makefile +++ b/dependencies/uci-analyser/Makefile @@ -31,7 +31,7 @@ ifeq ($(OS), Linux) # CFLAGS=-c -g -Wall -O3 -D__unix__ # PRODUCTION -CFLAGS= -static-libgcc -static-libstdc++ -std=c++17 -c -O3 -DPRODUCTION -D__unix__ +CFLAGS=-std=c++17 -c -O3 -DPRODUCTION -D__unix__ else # WINDOWS @@ -39,7 +39,7 @@ else # CFLAGS= -std=c++17 -c -g -Wall -O3 # PRODUCTION -CFLAGS= -static-libgcc -static-libstdc++ -std=c++17 -c -O3 -DPRODUCTION +CFLAGS=-std=c++17 -c -O3 -DPRODUCTION endif OBJS=analyse.o evaluation.o engine.o utils.o interpret.o @@ -49,7 +49,7 @@ TARGET=analyse $(CXX) $(CFLAGS) $< -o $@ $(TARGET) : $(OBJS) - $(CXX) -o $@ $(OBJS) + $(CXX) -static -static-libgcc -static-libstdc++ -std=c++17 -O3 -o $@ $(OBJS) clean: rm -f $(OBJS) $(TARGET)