diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index a7bc113e..113e2db8 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -1,7 +1,7 @@ name: Build Release Assets on: push: - branches: [master] + branches: [master, develop] workflow_dispatch: jobs: @@ -10,8 +10,8 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: master + # with: + # ref: master - name: Get Version Number id: version_number @@ -30,7 +30,7 @@ jobs: # TODO: Use specific GCC version gcc --version - + mkdir build && cd build cmake .. cmake --build . --target bladebit --config Release -j $(nproc --all) @@ -54,8 +54,8 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: master + # with: + # ref: master - name: Get Version Number id: version_number @@ -102,8 +102,8 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: master + # with: + # ref: master - name: Get Version Number id: version_number @@ -145,8 +145,8 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: master + # with: + # ref: master - name: Get Version Number id: version_number @@ -188,8 +188,8 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: master + # with: + # ref: master - name: Get Version Number shell: bash @@ -205,8 +205,15 @@ jobs: env: BB_ARTIFACT_NAME: ${{ steps.version_number.outputs.BB_ARTIFACT_NAME }} run: | + mkdir build && cd build cmake .. + + # We're having problems in windows with Version.h generation, + # so lets just call it manually + bash -e ../extract-version.sh + cat ../src/Version.h + cmake --build . --target bladebit --config Release mkdir ../bin diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a0ed2c3..04e54dfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,17 @@ message("Config: ${CMAKE_BUILD_TYPE}") project(bladebit) +# On CI, update Version.h from our VERSION file +if(DEFINED ENV{CI}) + message("Updating Version.h") + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + execute_process(COMMAND bash.exe extract-version.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + else() + execute_process(COMMAND bash extract-version.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + endif() +endif() + + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} @@ -133,7 +144,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") else() # *Nix - set(c_opts --include=pch.h -march=native -Wall -Wno-comment -Wno-unknown-pragmas -g ${c_opts}) + set(c_opts --include=pch.h -Wall -Wno-comment -Wno-unknown-pragmas -g ${c_opts}) set(release_c_opts -O3 -flto diff --git a/extract-version.sh b/extract-version.sh new file mode 100644 index 00000000..d91c8d52 --- /dev/null +++ b/extract-version.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env bash +set -e +set -o pipefail +_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" +cd $_dir + +set IFS= + +version_str=$(cat VERSION | xargs) +version_header='src/Version.h' + +ver_maj=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/' | xargs) +ver_min=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/' | xargs) +ver_rev=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\3/' | xargs) + +git_commit=$(git rev-parse HEAD) +echo "Version: $ver_maj.$ver_min.$ver_rev-$git_commit" + +sed -i -E -r "s/(#define BLADEBIT_VERSION_MAJ )([0-9]+)/\1$ver_maj/g" $version_header +sed -i -E -r "s/(#define BLADEBIT_VERSION_MIN )([0-9]+)/\1$ver_min/g" $version_header +sed -i -E -r "s/(#define BLADEBIT_VERSION_REV )([0-9]+)/\1$ver_rev/g" $version_header +sed -i -E -r "s/(#define BLADEBIT_GIT_COMMIT )(.+)/\1\"$git_commit\"/g" $version_header + diff --git a/src/Version.h b/src/Version.h index 7553d13c..9098d2ff 100644 --- a/src/Version.h +++ b/src/Version.h @@ -4,6 +4,8 @@ #define BLADEBIT_VERSION_MIN 2 #define BLADEBIT_VERSION_REV 0 +#define BLADEBIT_GIT_COMMIT "dev" + #define BLADEBIT_VERSION \ ((uint64)BLADEBIT_VERSION_MAJ) << 32 \ ((uint64)BLADEBIT_VERSION_MIN) << 16 \ diff --git a/src/main.cpp b/src/main.cpp index 7b62ef87..f0c85a34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -728,8 +728,10 @@ inline std::vector BytesConcat( std::vector a, std::vector