Browse Source

CMake will try to generate version string when not specified

release/1.1
Jessica James 3 years ago
parent
commit
af5b18f80c
  1. 12
      .github/workflows/cmake.yml
  2. 45
      .github/workflows/release.yml
  3. 33
      CMakeLists.txt

12
.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: env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Debug
BUILD_TYPE: Release
jobs: jobs:
ubuntu-build: ubuntu-build:
@ -26,7 +26,7 @@ jobs:
- name: Configure CMake - name: Configure CMake
working-directory: ${{github.workspace}}/build 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 - name: Build
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
@ -55,7 +55,7 @@ jobs:
- name: Configure CMake - name: Configure CMake
working-directory: ${{github.workspace}}/build 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 - name: Build
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build

45
.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.*

33
CMakeLists.txt

@ -3,6 +3,39 @@ project(jupiter_bot)
set(CMAKE_CXX_STANDARD 20) 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) if (DEFINED JUPITER_VERSION_SHORT)
add_compile_definitions(JUPITER_VERSION_SHORT="${JUPITER_VERSION_SHORT}") add_compile_definitions(JUPITER_VERSION_SHORT="${JUPITER_VERSION_SHORT}")
endif() endif()

Loading…
Cancel
Save