|
1 | | -name: cpp_tutorial CI |
| 1 | +name: cpp_tutorial CI and Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [ "master" ] |
6 | 6 | pull_request: |
7 | 7 | branches: [ "master" ] |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - 'v*.*.*' # Trigger workflow on version tags (e.g., v1.0.0) |
8 | 11 |
|
9 | 12 | jobs: |
10 | 13 | build: |
11 | 14 | runs-on: ubuntu-22.04 |
12 | 15 |
|
13 | 16 | steps: |
| 17 | + # Step 1: Checkout the repository |
14 | 18 | - uses: actions/checkout@v3 |
15 | 19 | name: Checkout the repository |
16 | 20 |
|
| 21 | + # Step 2: Build the Docker image |
17 | 22 | - name: Build the Docker image |
18 | 23 | run: docker build . --file Dockerfile --tag mycpp_image:latest |
19 | 24 |
|
20 | | - # Debugging: List contents of the GitHub workspace |
21 | | - - name: List contents of the repository |
22 | | - run: ls -la |
23 | | - |
| 25 | + # Step 3: Configure CMake |
24 | 26 | - name: Configure CMake |
25 | 27 | run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake -S /cpp_tutorials -G "Ninja Multi-Config" -B /cpp_tutorials/build |
26 | 28 |
|
| 29 | + # Step 4: Build with CMake |
27 | 30 | - name: Build with CMake |
28 | 31 | run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake --build /cpp_tutorials/build --config Release |
29 | 32 |
|
30 | | - # Uncomment this step if you want to run tests |
31 | | - # - name: Run tests |
32 | | - # run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest ctest -C Release -S /cpp_tutorials/build |
33 | | - |
| 33 | + # Step 5: Generate Doxygen documentation |
34 | 34 | - name: Generate Doxygen documentation |
35 | 35 | run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest doxygen /cpp_tutorials/Doxyfile |
36 | 36 |
|
37 | | - - name: List generated documentation files |
38 | | - run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest ls -la /cpp_tutorials/docs |
| 37 | + # Step 6: Upload documentation as an artifact |
| 38 | + - name: Upload documentation |
| 39 | + uses: actions/upload-artifact@v3 |
| 40 | + with: |
| 41 | + name: cpp_documentation |
| 42 | + path: /cpp_tutorials/docs |
| 43 | + |
| 44 | + # Step 7: Upload build artifacts as an artifact (e.g., binaries or build output) |
| 45 | + - name: Upload build artifacts |
| 46 | + uses: actions/upload-artifact@v3 |
| 47 | + with: |
| 48 | + name: cpp_build_output |
| 49 | + path: /cpp_tutorials/build |
| 50 | + |
| 51 | + release: |
| 52 | + needs: build |
| 53 | + runs-on: ubuntu-22.04 |
| 54 | + |
| 55 | + steps: |
| 56 | + # Step 1: Checkout the repository |
| 57 | + - uses: actions/checkout@v3 |
| 58 | + name: Checkout the repository |
| 59 | + |
| 60 | + # Step 2: Create a GitHub release |
| 61 | + - name: Create Release |
| 62 | + id: create_release |
| 63 | + uses: actions/create-release@v1 |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + with: |
| 67 | + tag_name: ${{ github.ref }} |
| 68 | + release_name: Release ${{ github.ref }} |
| 69 | + body: | |
| 70 | + Release notes for this version. |
| 71 | + draft: false |
| 72 | + prerelease: false |
| 73 | + |
| 74 | + # Step 3: Upload build artifacts to the release |
| 75 | + - name: Upload build artifacts to release |
| 76 | + uses: actions/upload-release-asset@v1 |
| 77 | + with: |
| 78 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 79 | + asset_path: /cpp_tutorials/build/your_build_artifact # Adjust to your actual artifact |
| 80 | + asset_name: your_build_artifact_name # Name the artifact file as you want |
| 81 | + asset_content_type: application/octet-stream |
| 82 | + |
| 83 | + # Step 4: Upload documentation to the release |
| 84 | + - name: Upload documentation to release |
| 85 | + uses: actions/upload-release-asset@v1 |
| 86 | + with: |
| 87 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 88 | + asset_path: /cpp_tutorials/docs |
| 89 | + asset_name: cpp_documentation |
| 90 | + asset_content_type: application/zip |
39 | 91 |
|
0 commit comments