diff --git a/.github/workflows/cmake_build.yml b/.github/workflows/cmake_build.yml new file mode 100644 index 0000000..12a07a5 --- /dev/null +++ b/.github/workflows/cmake_build.yml @@ -0,0 +1,35 @@ +name: CMake Build + +on: + push: + tags: + - "v*" + +jobs: + build: + # 可以更换为ubuntu-{24.04, 22.04, 20.04},默认为ubuntu-24.04 + runs-on: ubuntu-24.04 + + steps: + - name: Install Dependencies + run: | + apt update + apt install -y cmake build-essential + - uses: actions/checkout@v4 + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release + + - name: Build Project + run: cmake --build ${{github.workspace}}/build --config Release --parallel 8 + + - name: Strip Binary + run: strip ${{github.workspace}}/build/cpp_example + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: ${{github.workspace}}/build/cpp_example + draft: false + prerelease: false + generate_release_notes: true + token: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index 4fa1c75..a261825 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ CTestTestfile.cmake _deps CMakeUserPresets.json + +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5629f8c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.10) + +project(cpp_example) + +add_executable(cpp_example main.cpp) \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..274e01a --- /dev/null +++ b/main.cpp @@ -0,0 +1,5 @@ +#include +int main() { + std::cout << "Hello, World!" << '\n'; + return 0; +} \ No newline at end of file