diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 40dd9f4..6f45760 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,10 +1,10 @@ -name: CMake +name: Debug CI -on: [push] +# Run debug builds on all branches & PRs +on: [push, pull_request] env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release + BUILD_TYPE: Debug jobs: ubuntu-build: @@ -26,7 +26,7 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE "-DJUPITER_VERSION_SHORT=Ubuntu.SHA-$(git rev-parse --short $GITHUB_SHA)" + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - name: Build working-directory: ${{github.workspace}}/build @@ -55,7 +55,7 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/build - run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE "-DJUPITER_VERSION_SHORT=Win.SHA-$(git rev-parse --short $env:GITHUB_SHA)" + run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE - name: Build working-directory: ${{github.workspace}}/build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0f09195 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Windows Release + +# Run release builds only on release branches +on: + push: + branches: + - release/* + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + # Only want Windows release builds for now; Linux users can very easily install from source + windows-build: + runs-on: windows-latest + + steps: + # Checkout git repo & submodules + - uses: actions/checkout@v2 + with: + submodules: recursive + + # Create working directory & install non-default dependencies (openssl) + - name: Create Build Environment + run: | + cmake -E make_directory ${{github.workspace}}/build + choco install openssl + + # Generate make files + - name: Configure CMake + working-directory: ${{github.workspace}}/build + run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE + + # Make + - name: Build + working-directory: ${{github.workspace}}/build + run: cmake --build . --config $env:BUILD_TYPE --target=PackagedBuild + + # Publish build as an artifact + - name: Archive build package / binaries + uses: actions/upload-artifact@v2 + with: + name: windows-package + path: ${{github.workspace}}/bin/Jupiter Bot Binaries.* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c659e18..c43bab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,39 @@ project(jupiter_bot) set(CMAKE_CXX_STANDARD 20) +# Try to set JUPITER_VERSION_SHORT if it isn't already +if (NOT DEFINED JUPITER_VERSION_SHORT) + find_package(Git) + if (GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD + OUTPUT_VARIABLE JUPITER_VERSION_SHORT + RESULT_VARIABLE git_result + ) + string(STRIP "${JUPITER_VERSION_SHORT}" JUPITER_VERSION_SHORT) + + # Append sha1 if not release/ + if (git_result EQUAL 0 + AND NOT JUPITER_VERSION_SHORT MATCHES "^release/.*") + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + OUTPUT_VARIABLE GIT_REVISION + RESULT_VARIABLE git_result + ) + string(STRIP "${GIT_REVISION}" GIT_REVISION) + + if (git_result EQUAL 0) + set(JUPITER_VERSION_SHORT "${JUPITER_VERSION_SHORT}-${GIT_REVISION}") + endif() + elseif(JUPITER_VERSION_SHORT MATCHES "^release/*") + # set JUPITER_VERSION_SHORT to end of release/ + string(REGEX REPLACE "^release/" "" JUPITER_VERSION_SHORT "${JUPITER_VERSION_SHORT}") + message(FATAL_ERROR "release JUPITER_VERSION_SHORT: ${JUPITER_VERSION_SHORT}") + endif() + endif() +endif() + +message(FATAL_ERROR "JUPITER_VERSION_SHORT: >${JUPITER_VERSION_SHORT}<") if (DEFINED JUPITER_VERSION_SHORT) add_compile_definitions(JUPITER_VERSION_SHORT="${JUPITER_VERSION_SHORT}") endif()