From d0d9e2f13ea9c957b68eba138425433812abf500 Mon Sep 17 00:00:00 2001 From: AkiVer Date: Sat, 28 Oct 2023 00:56:39 +0200 Subject: [PATCH] chore: test build --- .github/workflows/release.yml | 219 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 16 ++- README.md | 62 +++++----- cleanup.sh | 2 +- cmake/FindSteamworks.cmake | 10 +- 5 files changed, 272 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a6e738b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,219 @@ +name: Publish new release + +on: push +# on: workflow_dispatch + +jobs: + build-windows-x64: + name: Build Windows x64 + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install deps + shell: bash + run: | + curl https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.zip -L --output protobuf.zip + unzip -q protobuf.zip + mv protobuf-3.20.3 protobuf + curl https://partner.steamgames.com/downloads/steamworks_sdk.zip --output steamworks_sdk.zip -L + unzip -q steamworks_sdk.zip -d steamworks_sdk + + - name: Build protobuf + shell: bash + run: | + cd protobuf/cmake && mkdir build + cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=.\build . + cmake --build . --config Release + cd ../.. + echo "${{ github.workspace }}/protobuf/cmake/Release" >> $GITHUB_PATH + + - name: Build boiler-writter + shell: bash + run: | + cmake . -DCMAKE_BUILD_TYPE=Release + cmake --build . --config Release + mkdir tmp && cp -r bin tmp && rm -rf bin && mv tmp bin + + - uses: actions/upload-artifact@v3 + with: + name: windows-x64 + path: bin + + build-macos-arm64: + name: Build macOS ARM64 + runs-on: macos-latest-xlarge + # TODO enable it when RM64 runners are free for public repos and adjsut the rest of the workflow + # https://github.com/actions/runner-images/issues/8439#issuecomment-1755601587 + if: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install deps + run: | + curl https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.zip -L --output protobuf.zip + unzip -q protobuf.zip + mv protobuf-3.20.3 protobuf + curl https://partner.steamgames.com/downloads/steamworks_sdk.zip --output steamworks_sdk.zip -L + unzip -q steamworks_sdk.zip -d steamworks_sdk + brew install automake autoconf libtool + + - name: Build protobuf + run: | + cd protobuf + ./autogen.sh + ./configure CXXFLAGS="-DNDEBUG" + make -j$(sysctl -n hw.physicalcpu) + sudo make install + cd .. + + - name: Build boiler-writter + run: | + cmake . -DCMAKE_BUILD_TYPE=Release + cmake --build . --config Release + mkdir tmp && cp -r bin tmp && rm -rf bin && mv tmp bin + + - uses: actions/upload-artifact@v3 + with: + name: macos-arm64 + path: bin + + build-macos-x64: + name: Build macOS x64 + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install deps + run: | + curl https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.zip -L --output protobuf.zip + unzip -q protobuf.zip + mv protobuf-3.20.3 protobuf + curl https://partner.steamgames.com/downloads/steamworks_sdk.zip --output steamworks_sdk.zip -L + unzip -q steamworks_sdk.zip -d steamworks_sdk + brew install automake + + - name: Build protobuf + run: | + cd protobuf + ./autogen.sh + ./configure CXXFLAGS="-DNDEBUG" + make -j$(sysctl -n hw.physicalcpu) + sudo make install + cd .. + + - name: Build boiler-writter + run: | + cmake . -DCMAKE_BUILD_TYPE=Release + cmake --build . --config Release + mkdir tmp && cp -r bin tmp && rm -rf bin && mv tmp bin + + - uses: actions/upload-artifact@v3 + with: + name: macos-x64 + path: bin + + build-linux-x64: + name: Build Linux x64 + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install deps + run: | + curl https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.zip -L --output protobuf.zip + unzip -q protobuf.zip + mv protobuf-3.20.3 protobuf + curl https://partner.steamgames.com/downloads/steamworks_sdk.zip --output steamworks_sdk.zip -L + unzip -q steamworks_sdk.zip -d steamworks_sdk + sudo apt-get install build-essential autoconf gcc gcc-multilib g++-multilib libtool -y + + - name: Build protobuf + run: | + cd protobuf + ./autogen.sh + ./configure CXXFLAGS="-DNDEBUG" + make -j$(nproc) + sudo make install + sudo ldconfig + cd .. + + - name: Build boiler-writter + run: | + cmake . -DCMAKE_BUILD_TYPE=Release + cmake --build . --config Release + mkdir tmp && cp -r bin tmp && rm -rf bin && mv tmp bin + + - uses: actions/upload-artifact@v3 + with: + name: linux-x64 + path: bin + + publish-release: + name: Publish release + runs-on: ubuntu-latest + needs: + [build-windows-x64, build-macos-x64, build-linux-x64] + # [build-windows-x64, build-macos-arm64, build-macos-x64, build-linux-x64] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Download artifacts + uses: actions/download-artifact@v3 + + - name: Create new version + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com + npm version minor -m "chore: v%s" + echo "VERSION=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV" + + - name: Build archives + run: | + cd windows-x64 && zip -r ../"boiler-writter-win-$VERSION.zip" bin && cd - + chmod +x macos-x64/bin/boiler-writter + cd macos-x64 && zip -r ../"boiler-writter-mac-$VERSION.zip" bin && cd - + chmod +x linux-x64/bin/boiler-writter + cd linux-x64 && zip -r ../"boiler-writter-linux-$VERSION.zip" bin && cd - + # chmod +x macos-arm64/bin/boiler-writter + # cd macos-arm64 && zip -r ../"boiler-writter-mac-arm64-$VERSION.zip" bin && cd - + + - name: Publish NPM + run: | + mkdir -p dist/bin/{darwin-arm64,darwin-x64,linux-x64,win32-x64} + cp windows-x64/bin/* dist/bin/win32-x64 + cp macos-x64/bin/* dist/bin/darwin-x64 + cp linux-x64/bin/* dist/bin/linux-x64 + zip -r "dist-npm.zip" dist + # cp macos-arm64/bin/* dist/bin/darwin-arm64 + # npm publish --dry-run + env: + NPM_GITHUB_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_EMAIL: ${{ secrets.NPM_EMAIL }} + + - name: GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: v${{ env.VERSION }} + allowUpdates: true + draft: true + replacesArtifacts: true + artifacts: "boiler-writter-*.zip,dist-npm.zip" + + # - name: Push the tag to GitHub + # run: git push origin main --tags diff --git a/CMakeLists.txt b/CMakeLists.txt index f6c39ed..0a92057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread --std=c++14") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(Protobuf_USE_STATIC_LIBS ON) +set(Protobuf_SRC_ROOT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/protobuf) include(FindPackageHandleStandardArgs) @@ -18,11 +19,15 @@ find_package(Steamworks REQUIRED) if (WIN32) if(CMAKE_BUILD_TYPE MATCHES Release) set(PROTOBUF_LIB_DIR Release) + set(PROTOBUF_LIB_NAME libprotobuf) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") else() set(PROTOBUF_LIB_DIR Debug) + set(PROTOBUF_LIB_NAME libprotobufd) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") endif() - set(Protobuf_SRC_ROOT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/protobuf) - set(Protobuf_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/vsprojects/${PROTOBUF_LIB_DIR}/libprotobuf.lib) + + set(Protobuf_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake/${PROTOBUF_LIB_DIR}/${PROTOBUF_LIB_NAME}.lib) endif() find_package(Protobuf REQUIRED) @@ -60,7 +65,7 @@ add_executable(boiler-writter include_directories(${STEAMWORKS_INCLUDE_DIR}) include_directories(${Protobuf_INCLUDE_DIRS}) -target_link_libraries(boiler-writter "${STEAMWORKS_LIBRARY}" ${Protobuf_LIBRARIES}) +target_link_libraries(boiler-writter ${Protobuf_LIBRARIES} ${STEAMWORKS_LIBRARY}) source_group("Generated Files" FILES ${CSTRIKE_GC_PROTO_SOURCES} @@ -84,7 +89,10 @@ source_group("Protobuf Files" FILES file(COPY "steam_appid.txt" DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) if (WIN32) - file(COPY ${STEAMWORKS_SDK_PATH}/${STEAMWORKS_BIN_PATH}/steam_api.dll DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + file(COPY ${STEAMWORKS_SDK_PATH}/${STEAMWORKS_BIN_PATH}/steam_api64.dll DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + add_custom_command(TARGET boiler-writter POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/boiler-writter.exe ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + add_custom_command(TARGET boiler-writter POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}) else() file(COPY ${STEAMWORKS_LIBRARY} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() + diff --git a/README.md b/README.md index d462311..ea8f91d 100644 --- a/README.md +++ b/README.md @@ -3,28 +3,26 @@ ## About This is a console application based on [Boiler](https://bitbucket.org/ACB/boiler/). -It retrieve the CMsgGCCStrike15_v2_MatchList protobuf message from Steam GC and write it into the file provided as argument. +It retrieves the CMsgGCCStrike15_v2_MatchList protobuf message from Steam GC and writes it into the file provided as an argument. Nothing more. ## Why? -I made this application to add the ability to download last matchmaking demos from the application [CSGO Demos Manager](https://github.com/akiver/CSGO-Demos-Manager). -As [Steamworks.NET](http://steamworks.github.io/) doesn't provide a way to communicate with the Steam Game Coordinator, I had to use the C++ Steamworks version. +I made this application to add the ability to download last matchmaking demos from the application [CS Demo Manager](https://github.com/akiver/CSGO-Demos-Manager). ## Usage -Ready to use executable for each platform can be downloaded from [GitHub](https://github.com/akiver/boiler-writter/releases). +A ready-to-use executable for each platform can be downloaded from [GitHub](https://github.com/akiver/boiler-writter/releases). ``` ./boiler-writter path_to_the_file_where_data_will_be_written [matchId outcomeId tokenId] ``` -The 3 optionals parameters are from a [CMsgGCCStrike15_v2_MatchListRequestFullGameInfo](https://github.com/SteamDatabase/Protobufs/blob/eeb5c60e9a6bf9f989b86bf77ec3d9e04a1bb8c6/csgo/cstrike15_gcmessages.proto#L823) message. If they are specified, it will write the `CMsgGCCStrike15_v2_MatchList` message for this specific match. +The 3 optional parameters must come from a [CMsgGCCStrike15_v2_MatchListRequestFullGameInfo](https://github.com/SteamDatabase/Protobufs/blob/eeb5c60e9a6bf9f989b86bf77ec3d9e04a1bb8c6/csgo/cstrike15_gcmessages.proto#L823) message. +If they are specified, it will write the `CMsgGCCStrike15_v2_MatchList` message for this specific match. ## Build -Build tested on Windows 10, MAC OS (Catalina) and Linux (Ubuntu 20). - ### Common tasks 1. Download the repo and extract it @@ -36,15 +34,15 @@ Build tested on Windows 10, MAC OS (Catalina) and Linux (Ubuntu 20). ### Windows -1. Download the [protoc 3.20.3 precompiled Windows binary](https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protoc-3.20.3-win32.zip) and extract it in a folder included in your `PATH` env variable -2. Ensure `protoc` is installed by running `protoc --version` from a cmd -3. Launch the protobuf solution `protobuf/vsprojects/protobuf.sln` in Visual Studio and migrate projects if required -4. Add `_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS` in `libprotobuf Project properties -> C/C++ -> Preprocessor Definitions` (Debug and / or Release config) -5. Add `#include ` in the file `zero_copy_stream_impl_lite.h` -6. Compile the project **libprotobuf** (Using Debug and / or Release) -7. `cmake . -DCMAKE_GENERATOR_PLATFORM=win32` (Add `-DCMAKE_BUILD_TYPE="Release"` to generate the project for Release build) -8. `cmake --build .` (Add `--config Release` if building for Release build) -9. Executable will be in the `bin` folder +1. Install protobuf - from the root folder run: + 1. `cd protobuf/cmake && mkdir build` + 2. `cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=.\build .` + 3. `cmake --build . --config Release` + 4. `cd ../..` + 5. Add the path `protobuf/cmake/Release` to your `PATH` environment variable (where `protoc.exe` is) +2. `cmake . -DCMAKE_BUILD_TYPE=Release` +3. `cmake --build . --config Release` +4. Executable will be in the `bin` folder A VS solution `BoilerWritter.sln` is also available. @@ -53,30 +51,34 @@ A VS solution `BoilerWritter.sln` is also available. > **Note** > To build the x86_64 version from an arm64 mac, run `/usr/bin/arch -x86_64 /bin/zsh ---login` before running the commands below. -1. Install protobuf, from the folder `protobuf` run: - 1. `brew install automake autoconf libtool` +1. `brew install automake autoconf libtool` +2. Install protobuf - from the root folder run: + 1. `cd protobuf` 2. `./autogen.sh` 3. `./configure CXXFLAGS="-DNDEBUG"` 4. `make -j$(sysctl -n hw.physicalcpu)` 5. `sudo make install` -2. Check if it has been installed by running `protoc --version` -3. From the root project folder: `cmake .` (add `-DCMAKE_BUILD_TYPE="Release"` for release build) -4. `cmake --build .` -5. Executable will be in the `bin` folder + 6. `cd ..` +3. Check if it has been installed by running `protoc --version` +4. `cmake . -DCMAKE_BUILD_TYPE=Release` +5. `cmake --build . --config Release` +6. Executable will be in the `bin` folder If you want to generate an Xcode project `cmake -G Xcode`. ### Linux 1. `sudo apt install build-essential autoconf gcc gcc-multilib g++-multilib libtool` -2. Install protobuf, from the folder `protobuf` run: - 1. `autoreconf -f -i -Wall,no-obsolete` - 2. `./configure` - 3. `make` - 4. `sudo make install` - 5. `sudo ldconfig` -3. `cmake .` (add `-DCMAKE_BUILD_TYPE="Release"` for release build) -4. `cmake --build .` +2. Install protobuf - from the root folder run: + 1. `cd protobuf` + 2. `./autogen.sh` + 3. `./configure CXXFLAGS="-DNDEBUG"` + 4. `make` + 5. `sudo make install` + 6. `sudo ldconfig` + 7. `cd ..` +3. `cmake . -DCMAKE_BUILD_TYPE=Release` +4. `cmake --build . --config Release` 5. Executable will be in the `bin` folder ## License diff --git a/cleanup.sh b/cleanup.sh index 0c7e436..22422a8 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -1,2 +1,2 @@ rm -Rf CMakeFiles CMakeScripts cmake_install.cmake CMakeCache.txt Makefile bin \ -*.vcxproj* *.sln .vs BoilerWritter.build BoilerWritter.xcodeproj *.cc *.h +*.vcxproj* *.sln .vs boiler-writter.dir win32 Release Debug BoilerWritter.build BoilerWritter.xcodeproj *.cc *.h diff --git a/cmake/FindSteamworks.cmake b/cmake/FindSteamworks.cmake index e58ed75..572fb19 100644 --- a/cmake/FindSteamworks.cmake +++ b/cmake/FindSteamworks.cmake @@ -1,9 +1,15 @@ set(STEAMWORKS_SDK_PATH "${CMAKE_SOURCE_DIR}/steamworks_sdk/sdk") +if (WIN32) + set(STEAMWORKS_LIB_NAME steam_api64) +else() + set(STEAMWORKS_LIB_NAME steam_api) +endif () + if (APPLE) set(STEAMWORKS_BIN_PATH "redistributable_bin/osx") elseif(WIN32) - set(STEAMWORKS_BIN_PATH "redistributable_bin") + set(STEAMWORKS_BIN_PATH "redistributable_bin/win64") else() set(STEAMWORKS_BIN_PATH "redistributable_bin/linux64") endif () @@ -15,7 +21,7 @@ find_path(STEAMWORKS_INCLUDE_DIR ) find_library(STEAMWORKS_LIBRARY - NAMES steam_api + NAMES ${STEAMWORKS_LIB_NAME} PATH_SUFFIXES ${STEAMWORKS_BIN_PATH} PATHS ${STEAMWORKS_SDK_PATH} )