Skip to content

Commit 607524d

Browse files
committed
action updated
1 parent b4925fe commit 607524d

File tree

1 file changed

+63
-11
lines changed

1 file changed

+63
-11
lines changed

.github/workflows/docker-build.yml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,91 @@
1-
name: cpp_tutorial CI
1+
name: cpp_tutorial CI and Release
22

33
on:
44
push:
55
branches: [ "master" ]
66
pull_request:
77
branches: [ "master" ]
8+
push:
9+
tags:
10+
- 'v*.*.*' # Trigger workflow on version tags (e.g., v1.0.0)
811

912
jobs:
1013
build:
1114
runs-on: ubuntu-22.04
1215

1316
steps:
17+
# Step 1: Checkout the repository
1418
- uses: actions/checkout@v3
1519
name: Checkout the repository
1620

21+
# Step 2: Build the Docker image
1722
- name: Build the Docker image
1823
run: docker build . --file Dockerfile --tag mycpp_image:latest
1924

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
2426
- name: Configure CMake
2527
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake -S /cpp_tutorials -G "Ninja Multi-Config" -B /cpp_tutorials/build
2628

29+
# Step 4: Build with CMake
2730
- name: Build with CMake
2831
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest cmake --build /cpp_tutorials/build --config Release
2932

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
3434
- name: Generate Doxygen documentation
3535
run: docker run --rm -v ${{ github.workspace }}:/cpp_tutorials mycpp_image:latest doxygen /cpp_tutorials/Doxyfile
3636

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
3991

0 commit comments

Comments
 (0)