From 8ce18d724008efaef834ed2337752d83e10b6fb1 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Mon, 27 Feb 2023 23:04:44 +0100 Subject: [PATCH] Get version from CMakeLists.txt --- .github/workflows/python.yml | 16 ++++++++++++---- .github/workflows/wasmlib.yml | 7 ++++++- package.json | 2 +- pyproject.toml | 4 ++-- src/CMakeLists.txt | 7 +++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 91333a20..d571034f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -21,8 +21,12 @@ jobs: if [[ "${GITHUB_REF}" == refs/tags/* ]]; then version="${GITHUB_REF##*/}" else - # version="$(git describe --tags).dev${GITHUB_RUN_NUMBER}" - version="3.1.0.dev${GITHUB_RUN_NUMBER}" + mkdir empty-build + cd empty-build + cmake .. -DENABLE_GUI=OFF -DENABLE_CLI=OFF -DENABLE_TESTS=OFF -DENABLE_COVERAGE=OFF -DENABLE_SANITIZERS=OFF -DENABLE_OPENMP=OFF + source version.env + cd .. + version="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.dev${GITHUB_RUN_NUMBER}" fi sed -i.bak "s/^version = .*/version = \"${version}\"/g" pyproject.toml && rm pyproject.toml.bak python -m pip install -U setuptools build @@ -108,8 +112,12 @@ jobs: if [[ "${GITHUB_REF}" == refs/tags/* ]]; then version="${GITHUB_REF##*/}" else - # version="$(git describe --tags).dev${GITHUB_RUN_NUMBER}" - version="3.1.0.dev${GITHUB_RUN_NUMBER}" + mkdir empty-build + cd empty-build + cmake .. -DENABLE_GUI=OFF -DENABLE_CLI=OFF -DENABLE_TESTS=OFF -DENABLE_COVERAGE=OFF -DENABLE_SANITIZERS=OFF -DENABLE_OPENMP=OFF + source version.env + cd .. + version="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.dev${GITHUB_RUN_NUMBER}" fi sed -i.bak "s/^version = .*/version = \"${version}\"/g" pyproject.toml && rm pyproject.toml.bak - name: Set up QEMU diff --git a/.github/workflows/wasmlib.yml b/.github/workflows/wasmlib.yml index 94c7c3a8..efdb1b8a 100644 --- a/.github/workflows/wasmlib.yml +++ b/.github/workflows/wasmlib.yml @@ -55,7 +55,12 @@ jobs: if [[ "${GITHUB_REF}" == refs/tags/* ]]; then version="${GITHUB_REF##*/}" else - version="3.1.0-dev.${GITHUB_RUN_NUMBER}" + mkdir empty-build + cd empty-build + cmake .. -DENABLE_GUI=OFF -DENABLE_CLI=OFF -DENABLE_TESTS=OFF -DENABLE_COVERAGE=OFF -DENABLE_SANITIZERS=OFF -DENABLE_OPENMP=OFF + source version.env + cd .. + version="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-dev.${GITHUB_RUN_NUMBER}" is_dev="1" fi jq --arg version "${version}" '.version = $version' package.json > package.json.tmp diff --git a/package.json b/package.json index 8f4681bc..c9188b7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slvs", - "version": "1.0.0", + "version": "0.0.0", "description": "\"SolveSpace", "main": "slvs.js", "types": "slvs.d.ts", diff --git a/pyproject.toml b/pyproject.toml index f7a99963..1941e361 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "scikit_build_core.build" [project] name = "solvespace" -version = "3.1.0" -description="A minimal example package (with pybind11)" +version = "0.0.0" +description="SolveSpace solver wrapped with Cython" readme = "README.md" authors = [ { name = "Koen Schmeets", email = "koen@schmeets.de" }, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb8c8342..e922831b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,6 +118,13 @@ if(ENABLE_EMSCRIPTEN_LIB) --closure 1") endif() +file(WRITE ${CMAKE_BINARY_DIR}/version.env "\ +VERSION_MAJOR=${PROJECT_VERSION_MAJOR}\n\ +VERSION_MINOR=${PROJECT_VERSION_MINOR}\n\ +VERSION_PATCH=0\n\ +VERSION_GIT_HASH=${solvespace_GIT_HASH}\n\ +") + if(ENABLE_PYTHON_LIB) add_custom_command( OUTPUT lib.c