From 22ed0c91e777553b0a99c1ec82fb06e784fdee93 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sun, 28 Nov 2021 16:18:52 +0100 Subject: [PATCH] Add workflow --- .github/FUNDING.yml | 1 + .github/workflows/build.yaml | 118 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 37 +++++++---- 3 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/build.yaml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9f8d5bb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [ArthurSonzogni] diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..90de23b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,118 @@ +name: Build + +on: + create: + tags: + -v* + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + name: "Tests" + strategy: + matrix: + include: + - name: Linux GCC + os: ubuntu-latest + compiler: g++-9 + test: true + + - name: Linux Clang + os: ubuntu-latest + compiler: clang++ + test: true + + - name: MacOS clang + os: macos-latest + compiler: clang++ + test: true + + - name: Windows MSVC + os: windows-latest + compiler: cl + test: false + + runs-on: ${{ matrix.os }} + steps: + - name: "Checkout repository" + uses: actions/checkout@v2 + + - name: "Enable MSVC command prompt" + if: matrix.os == 'windows-latest' + uses: ilammy/msvc-dev-cmd@v1 + + - name: "Install cmake" + uses: lukka/get-cmake@latest + + - name: "Build debug mode" + run: > + mkdir build; + cd build; + cmake .. + -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} + -DFTXUI_BUILD_DOCS=OFF + -DFTXUI_BUILD_EXAMPLES=OFF + -DFTXUI_BUILD_TESTS=OFF + -DFTXUI_BUILD_TESTS_FUZZER=OFF + -DFTXUI_ENABLE_INSTALL=OFF; + cmake --build . --config Debug; + + # Create a release on new v* tags + release: + if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }} + name: "Create release" + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: "Create release" + uses: softprops/action-gh-release@v1 + id: create_release + with: + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Build artifact for the release + package: + name: "Build packages" + needs: release + strategy: + matrix: + include: + - os: ubuntu-latest + asset_path: build/rgb-tui*Linux* + - os: macos-latest + asset_path: build/rgb-tui*Darwin* + - os: windows-latest + asset_path: build/rgb-tui*Win64* + runs-on: ${{ matrix.os }} + steps: + - name: "Checkout repository" + uses: actions/checkout@v2 + + - name: "Install cmake" + uses: lukka/get-cmake@latest + + - name: "Build packages" + run: > + mkdir build; + cd build; + cmake .. + -DCMAKE_BUILD_TYPE=Release + -DFTXUI_BUILD_DOCS=OFF + -DFTXUI_BUILD_EXAMPLES=OFF + -DFTXUI_BUILD_TESTS=OFF + -DFTXUI_BUILD_TESTS_FUZZER=OFF + -DFTXUI_ENABLE_INSTALL=OFF; + cmake --build . --config Release --target package; + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ${{ matrix.asset_path }} + overwrite: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ae7958..f50d862 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,22 +48,33 @@ target_link_libraries(rgb-tui # C++17 is used. We requires fold expressions at least. set_target_properties(rgb-tui PROPERTIES CXX_STANDARD 17) +# ------------------------------------------------------------------------------ + install(TARGETS rgb-tui RUNTIME DESTINATION "bin") -set(CPACK_GENERATOR "DEB") -set(CPACK_PACKAGE_NAME "rgb-tui") -set(CPACK_PACKAGE_VENDOR "Arthur Sonzogni") +# ------------------------------------------------------------------------------ +if (UNIX AND NOT APPLE) + set(CPACK_GENERATOR "DEB;External;RPM;STGZ;TBZ2;TGZ;TXZ;TZ;TZST;ZIP") +elseif (UNIX AND APPLE) + set(CPACK_GENERATOR "DragNDrop;NuGet;TGZ;ZIP") +elseif (WIN32) + set(CPACK_GENERATOR "DEB;NuGet;TGZ;ZIP") +else() + set(CPACK_GENERATOR "ZIP") +endif() + +set(CPACK_DEBIAN_PACKAGE_DEPENDS " ") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE_URL "https://github.com/ArthurSonzogni/rgb-tui/") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arthur Sonzogni") -set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION}) -set(CPACK_PACKAGE_VERSION_MINOR "") -set(CPACK_PACKAGE_VERSION_PATCH "") set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION}) -set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/rgb-tui/") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - A color picker with a terminal UI. -") -set(CPACK_DEBIAN_PACKAGE_DEPENDS " ") -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE_URL "https://github.com/rgb-tui/") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A color picker with a terminal UI.") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/ArthurSonzogni/rgb-tui/") +set(CPACK_PACKAGE_NAME "rgb-tui") +set(CPACK_PACKAGE_VENDOR "Arthur Sonzogni") +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") include(CPack) -