diff --git a/.github/workflows/release.sh b/.github/workflows/release.sh new file mode 100644 index 0000000..dc25df6 --- /dev/null +++ b/.github/workflows/release.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Release script run in Github CI + +BRANCH="$1" + +LAST_TAG=$(git tag | sort -t '.' --numeric-sort -k1,1 -k2,2 -k3,3 | tail -n 1) +LAST_TAG_MAJOR=$(echo "$LAST_TAG" | cut -d'.' -f1) +LAST_TAG_MINOR=$(echo "$LAST_TAG" | cut -d'.' -f2) +LAST_TAG_PATCH=$(echo "$LAST_TAG" | cut -d'.' -f3) + +git show --compact-summary "$LAST_TAG..HEAD" > CHANGELOG + +TAG_MAJOR="" +TAG_MINOR="" +TAG_PATCH="" + +WARNINGS="" + +if grep -q "^ MAJOR" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 1)) + TAG_MINOR="0" + TAG_PATCH="0" +elif grep -q "^ MINOR" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 1)) + TAG_PATCH="0" +elif grep -q "^ PATCH" CHANGELOG; then + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 0)) + TAG_PATCH=$((LAST_TAG_PATCH + 1)) +else + WARNINGS="$WARNINGS ; This release is created with default bump version because no commits was ok" + TAG_MAJOR=$((LAST_TAG_MAJOR + 0)) + TAG_MINOR=$((LAST_TAG_MINOR + 0)) + TAG_PATCH=$((LAST_TAG_PATCH + 1)) +fi + +TAG="$TAG_MAJOR.$TAG_MINOR.$TAG_PATCH" + +gh release create "$TAG" \ + --title "v$TAG" \ + --generate-notes \ + --target "$BRANCH" + +echo "release_tag=$TAG" >> $GITHUB_OUTPUT +echo "$WARNINGS" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..94b0066 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,113 @@ +name: Release + +on: + push: + branches: [main, dev] + +env: + BRANCH: "main" + DATE_TAG: "v3.0.1" + +jobs: + release-create: + permissions: write-all + runs-on: ubuntu-latest + + outputs: + release: ${{ steps.release.outputs.release_tag }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - id: release + name: Create Release + if: github.repository != 'EpitechPromo2026/B-CPP-500-TLS-5-1-rtype-xavier.mitault.git' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then + export GITHUB_OUTPUT=$GITHUB_OUTPUT + bash ./.github/workflows/release.sh "${{ env.BRANCH }}" + else + echo "release_tag=0.0.0" >> $GITHUB_OUTPUT + fi + + test-ecs: + runs-on: ubuntu-latest + needs: [release-linux] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Change directory + run: cd test + + - name: Build test + run: ./scripts/compil.sh + + release-linux: + runs-on: ubuntu-latest + needs: [release-create, date-to-tar] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cleanup + run: ./scripts/cleanup.sh + + - name: Create tar + run: ./scripts/create-tar.sh + + - name: Upload To Release + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ needs.release-create.outputs.release }} ./b-luga.tar + + - name: Upload To Artifact + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: b-luga.tar + path: ./b-luga.tar + + date-to-tar: + runs-on: ubuntu-latest + needs: release-create + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install deps + run: sudo apt-get update && sudo apt-get install -y tar git + + - name: Get Date + run: | + git clone https://github.com/HowardHinnant/date.git date-repo + cd date-repo || exit 14 + git checkout ${{ env.DATE_TAG }} + cd .. + + - name: To Tar + run: | + tar -cvf date.tar date-repo + + - name: Upload To Release + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ needs.release-create.outputs.release }} ./date.tar + + - name: Upload To Artifact + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v3 + with: + name: date.tar + path: ./date.tar diff --git a/.github/workflows/test-ecs.yml b/.github/workflows/test-ecs.yml new file mode 100644 index 0000000..757648a --- /dev/null +++ b/.github/workflows/test-ecs.yml @@ -0,0 +1,11 @@ +name: Test ECS + +on: + push: + branches: [main] + +env: + BRANCH: "main" + +jobs: + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1dba557 --- /dev/null +++ b/.gitignore @@ -0,0 +1,209 @@ +# Created by https://www.toptal.com/developers/gitignore/api/c++,c,clion,cmake +# Edit at https://www.toptal.com/developers/gitignore?templates=c++,c,clion,cmake + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### C++ ### +# Prerequisites + +# Compiled Object files +*.slo + +# Precompiled Headers + +# Compiled Dynamic libraries + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai + +# Executables + +### CLion ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### CLion Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +# End of https://www.toptal.com/developers/gitignore/api/c++,c,clion,cmake + +build/* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5861b49 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.20) + +set(PROJECT_NAME "b-luga") + +project( + ${PROJECT_NAME} + VERSION 1.0.0 + LANGUAGES CXX + DESCRIPTION "ECS made for R-Type epitech project" +) + +add_library(${PROJECT_NAME} INTERFACE) +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +set(BLUGA_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/") +set(BLUGA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") + +target_include_directories( + ${PROJECT_NAME} + INTERFACE + $ + $ +) + +include(CMakePackageConfigHelpers) + +install( + DIRECTORY ${BLUGA_INCLUDE_BUILD_DIR} + DESTINATION ${BLUGA_INCLUDE_INSTALL_DIR} +) + +export( + TARGETS ${PROJECT_NAME} + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}Config.cmake +) + +install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets + INCLUDES DESTINATION ${BLUGA_INCLUDE_INSTALL_DIR} +) +install( + EXPORT ${PROJECT_NAME}Targets + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${BLUGA_INCLUDE_INSTALL_DIR} +) diff --git a/include/ECSTests.hpp b/include/ECSTests.hpp new file mode 100644 index 0000000..ffe0991 --- /dev/null +++ b/include/ECSTests.hpp @@ -0,0 +1,10 @@ +#pragma once +#include +namespace ECS { + class ABC { + public: + static void test() { + std::cout << "ABC" << std::endl; + } + }; +} diff --git a/include/Folder/Test.hpp b/include/Folder/Test.hpp new file mode 100644 index 0000000..e198a3e --- /dev/null +++ b/include/Folder/Test.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace ECS::Folder { + class DEF { + public: + static void test() { + std::cout << "DEF" << std::endl; + } + }; +} diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh new file mode 100755 index 0000000..7a172cb --- /dev/null +++ b/scripts/cleanup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -ex + +rm -rf ./.github/ +rm -rf ./build +rm -rf ./test +rm -rf ./.gitignore diff --git a/scripts/create-tar.sh b/scripts/create-tar.sh new file mode 100644 index 0000000..1ae3545 --- /dev/null +++ b/scripts/create-tar.sh @@ -0,0 +1,7 @@ +NOW=$(pwd) + +cd .. + +tar -cvf b-luga.tar $NOW + +cd "$NOW" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..81409f8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,31 @@ +# ------------------------------ +# ------------------------------ +# ------------------------------ + +include(ExternalProject) + +include(FetchContent) + +FetchContent_Declare( + b-luga + URL "https://github.com/X-R-G-B/B-luga/releases/latest/download/raylib.tar" + DOWLOAD_EXTRACT_TIMESTAMP TRUE +) + +FetchContent_MakeAvailable(b-luga) + +# ------------------------------ +# ------------------------------ +# ------------------------------ + +set(PROJECT_NAME "test-ecs") + +project( + ${PROJECT_NAME} + VERSION 1.0.0 + LANGUAGES CXX +) + +add_executable(${PROJECT_NAME}) + +add_subdirectory(src) diff --git a/test/scripts/compil.sh b/test/scripts/compil.sh new file mode 100755 index 0000000..8071a85 --- /dev/null +++ b/test/scripts/compil.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -ex + +cmake -S . -B build + +cmake --build build diff --git a/test/src/CMakeLists.txt b/test/src/CMakeLists.txt new file mode 100644 index 0000000..bbaf124 --- /dev/null +++ b/test/src/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20) + +target_sources( + ${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp +) diff --git a/test/src/main.cpp b/test/src/main.cpp new file mode 100644 index 0000000..54338e4 --- /dev/null +++ b/test/src/main.cpp @@ -0,0 +1,7 @@ +#include "ECSTests.hpp" +#include "Folder/Test.hpp" + +int main() { + ECS::ABC::test(); + ECS::Folder::DEF::test(); +}