From b8df42d9bd0e9e00466f824c03ab9e331434c867 Mon Sep 17 00:00:00 2001 From: Kolyah35 Date: Tue, 17 Mar 2026 00:20:56 +0300 Subject: [PATCH] trying to up actions --- .github/workflows/cmake-multiplatform.yml | 75 +++++++++++++++++++++++ CMakeLists.txt | 54 +++++++++++++++- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cmake-multiplatform.yml diff --git a/.github/workflows/cmake-multiplatform.yml b/.github/workflows/cmake-multiplatform.yml new file mode 100644 index 0000000..a4ef1e1 --- /dev/null +++ b/.github/workflows/cmake-multiplatform.yml @@ -0,0 +1,75 @@ +name: CMake multiplatform + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: write + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Debug] + include: + - os: windows-latest + c_compiler: clang + cpp_compiler: clang++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + + steps: + - uses: actions/checkout@v4 + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Setup Environment + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt-get update -qq + sudo apt-get install gcc-multilib + sudo apt-get install -y --no-install-recommends build-essentials libgl-dev libwayland-dev xorg-dev libxkbcommon-dev + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Install + run: cmake --install ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Pack + run: | + cd ${{ steps.strings.outputs.build-output-dir }} + cpack -C ${{ matrix.build_type }} + + - name: Create or Update Development Release + uses: softprops/action-gh-release@v1 + with: + name: Development Build + tag_name: dev + body: | + ${{ github.event.head_commit.timestamp }} + draft: false + prerelease: true + generate_release_notes: false + files: 'build/package/*.zip' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index df0b881..d528514 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ CPMAddPackage( NAME "libpng" GIT_REPOSITORY "https://github.com/pnggroup/libpng.git" GIT_TAG "v1.6.55" + EXCLUDE_FROM_ALL TRUE OPTIONS "ZLIB_ROOT ${zlib_SOURCE_DIR}" "ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR}" @@ -34,6 +35,7 @@ CPMAddPackage( NAME "openal" GIT_REPOSITORY "https://github.com/kcat/openal-soft.git" GIT_TAG "1.25.1" + EXCLUDE_FROM_ALL TRUE OPTIONS "ALSOFT_EXAMPLES OFF" "ALSOFT_TESTS OFF" @@ -45,6 +47,7 @@ CPMAddPackage( NAME "glfw" GIT_REPOSITORY "https://github.com/glfw/glfw.git" GIT_TAG "3.4" + EXCLUDE_FROM_ALL TRUE OPTIONS "GLFW_BUILD_EXAMPLES OFF" "GLFW_BUILD_TESTS OFF" @@ -305,4 +308,53 @@ add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" $/data -) \ No newline at end of file +) + +# Installing and packing + +find_package(Git REQUIRED) + +execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_SHORTSHA + OUTPUT_STRIP_TRAILING_WHITESPACE +) +string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) +set(CPACK_PACKAGE_NAME "MCPE-0.6.1-for-all") +set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${SYSTEM_NAME}) +set(CPACK_PACKAGE_VENDOR "MCPE-0.6.1-for-all") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/package") +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install") +set(CPACK_GENERATOR "ZIP") + +set(GIT_REPO "https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1") + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION .) + +install(DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION .) + +string(TIMESTAMP CURRENT_DATE "%Y-%m-%d") +string(TIMESTAMP CURRENT_TIME "%H:%M:%S") + +set(VERSION_STR "${PROJECT_VERSION}") + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(VERSION_STR "${VERSION_STR} - Development Build") +endif() + +file(WRITE "${CMAKE_BINARY_DIR}/version.txt" +"Minecraft PE 0.6.1 + +Autogenerated file by cmake-${CMAKE_VERSION} +Report issues ${GIT_REPO}/issues + +Build date: ${CURRENT_DATE} ${CURRENT_TIME} +Build configuration: ${CMAKE_BUILD_TYPE} +Git commit: ${GIT_SHORTSHA} +Platform: ${CMAKE_SYSTEM_NAME}") + +install(FILES "${CMAKE_BINARY_DIR}/version.txt" DESTINATION .) + +include(CPack) \ No newline at end of file