diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e9b5de0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,61 @@ +name: Studio26F Main CI + +permissions: write-all + +on: + push: + branches: [ ci-*, main ] + tags: [ pre*, v* ] + pull_request: + branches: [ main ] + +jobs: + get-info: + runs-on: ubuntu-latest + outputs: + commitHash: ${{ steps.git-info.outputs.commitHash }} + steps: + - uses: actions/checkout@v4 + - name: Get git info + id: git-info + shell: bash + run: | + COMMIT_HASH=$(git rev-parse --short ${{ GITHUB.SHA }}) + echo "commitHash=$COMMIT_HASH" >> $GITHUB_OUTPUT + + build: + runs-on: ubuntu-latest + needs: get-info + env: + OUTPUT_FOLDER: ./build + RELEASE_FOLDER: ./release + strategy: + matrix: + config: [ Debug, Release ] + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: CMake Configure and Build + run: | + cmake -S "${{ github.workspace }}" -B "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" + cmake --build "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" --target Studio26F --config ${{ matrix.config }} + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: Studio26F_${{ needs.get-info.outputs.commitHash }}_${{ GITHUB.RUN_NUMBER }}_${{ matrix.config }} + path: "${{ env.OUTPUT_FOLDER }}/${{ matrix.config }}" + - name: Prepare for release + if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'release'}} + shell: bash + run: | + mkdir -p ${{ env.RELEASE_FOLDER }} + cp ${{ env.OUTPUT_FOLDER }}/${{ matrix.config }}/Studio26F ${{ env.RELEASE_FOLDER }} + - name: Upload release + if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'release'}} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: | + ${{ env.RELEASE_FOLDER }}/* + prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }} \ No newline at end of file diff --git a/.run/Studio26F.run.xml b/.run/Studio26F.run.xml deleted file mode 100644 index 41fc78a..0000000 --- a/.run/Studio26F.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.run/Studio26F_test.run.xml b/.run/Studio26F_test.run.xml deleted file mode 100644 index d23b110..0000000 --- a/.run/Studio26F_test.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d3a4a2..f02df23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,16 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") -message(STATUS "C++ standard set to ${CMAKE_CXX_STANDARD}") +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) +string(JSON VERSION_STRING GET ${VCPKG_JSON} version-string) +message(STATUS "Project version: ${VERSION_STRING}") project(Studio26F CXX) -add_compile_definitions(CMAKE_PROJECT_NAME="${PROJECT_NAME}") - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message(STATUS "Compiler is Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") @@ -24,6 +24,9 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX) endif () +add_compile_definitions(CMAKE_PROJECT_NAME="${PROJECT_NAME}") +add_compile_definitions(VERSION_STRING="${VERSION_STRING}") + add_executable(${PROJECT_NAME} main.cc types/Products.h) find_package(cryptopp CONFIG REQUIRED) diff --git a/main.cc b/main.cc index 77957d7..0b114ea 100644 --- a/main.cc +++ b/main.cc @@ -1,6 +1,7 @@ #include int main() { + LOG_INFO << std::format("{} v{} starting...", CMAKE_PROJECT_NAME, VERSION_STRING); drogon::app().loadConfigFile("config.json"); drogon::app().run(); return 0; diff --git a/vcpkg b/vcpkg index 0ba60bf..fe1cde6 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 0ba60bfef5dea4cb2599daa7ad8364e309835a68 +Subproject commit fe1cde61e971d53c9687cf9a46308f8f55da19fa diff --git a/vcpkg.json b/vcpkg.json index 8e6221a..63bbc5c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "studio26f", - "version-string": "0.1.0", + "version-string": "1.0.0", "maintainers": [ "Particle_G " ],