-
Notifications
You must be signed in to change notification settings - Fork 13
95 lines (78 loc) · 3.49 KB
/
docker-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: cpp_tutorial CI and Release
on:
push:
tags:
- 'v*.*.*' # Only trigger workflow on version tags (e.g., v1.0.0, v1.0.1)
jobs:
build:
runs-on: ubuntu-22.04
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v3
name: Checkout the repository
# Step 2: Build the Docker image
- name: Build the Docker image
run: docker build . --file Dockerfile --tag mycpp_image:latest
# Step 3: Configure CMake
- name: Configure CMake
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake -S /cpp_tutorials -G "Ninja Multi-Config" -B /cpp_tutorials/build
# Step 4: Build with CMake
- name: Build with CMake
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake --build /cpp_tutorials/build --config Release
# Step 5: Verify if build files are generated
- name: List build directory contents
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest ls -la /cpp_tutorials/build
# Step 6: Generate Doxygen documentation
- name: Generate Doxygen documentation
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest doxygen /cpp_tutorials/Doxyfile
# Step 7: Verify if documentation files are generated
- name: List documentation directory contents
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest ls -la /cpp_tutorials/docs
# Step 8: Upload documentation as an artifact (if files exist)
- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: cpp_documentation
path: /cpp_tutorials/docs
# Step 9: Upload build artifacts as an artifact (if files exist)
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: cpp_build_output
path: /cpp_tutorials/build
release:
needs: build
runs-on: ubuntu-22.04
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v3
name: Checkout the repository
# Step 2: Create a GitHub release using the version tag (e.g., v1.0.0, v1.0.1)
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }} # Use the pushed version tag as the release tag (e.g., v1.0.0)
release_name: Release ${{ github.ref_name }} # Name the release after the tag (e.g., v1.0.0)
body: |
Release notes for version ${{ github.ref_name }}.
draft: false
prerelease: false
# Step 3: Upload build artifacts to release
- name: Upload build artifacts to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /cpp_tutorials/build/Release/main # Adjust to your actual file
asset_name: main # Adjust this to name the artifact file
asset_content_type: application/octet-stream
# Step 4: Upload documentation to release
- name: Upload documentation to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /cpp_tutorials/docs
asset_name: cpp_documentation
asset_content_type: application/zip