Automatic release #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD - Automated Release | |
| on: | |
| push: | |
| branches: | |
| - main # Or 'master', depending on your default branch name | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install CMake and G++ | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake g++ | |
| - name: Configure CMake | |
| run: cmake -B build_cmake | |
| - name: Build project | |
| run: cmake --build build_cmake | |
| - name: Run tests | |
| # Assuming your CMake project has tests configured with CTest | |
| # If not, replace this with your actual test command (e.g., ./build_cmake/your_test_executable) | |
| run: ctest --test-dir build_cmake --output-on-failure | |
| create-github-release: | |
| needs: build-and-test # This job only runs if build-and-test job succeeds | |
| runs-on: ubuntu-latest | |
| if: success() # Ensure this job only runs if the previous job was successful | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get short commit SHA | |
| id: get_sha | |
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is automatically provided by GitHub Actions | |
| with: | |
| tag_name: release-${{ steps.get_sha.outputs.sha_short }} | |
| release_name: Automated Release - ${{ steps.get_sha.outputs.sha_short }} | |
| body: | | |
| Automated release based on commit: ${{ github.sha }} | |
| This release was automatically generated after all tests passed. | |
| draft: false | |
| prerelease: false |