Skip to content

Commit

Permalink
build: add CPack support (#129)
Browse files Browse the repository at this point in the history
* build: add CPack support

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* build: add default package preset

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* ci: modify build workflow to package project

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* chore: remove `install` directory from Git ignore list

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

---------

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
  • Loading branch information
threeal authored Oct 15, 2024
1 parent 536fda6 commit b53f96a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ jobs:
- name: Configure Project
run: cmake --preset default

- name: Install Project
run: cmake --install build --prefix install
- name: Package Project
run: cpack --preset default

- name: Upload Project
uses: actions/upload-artifact@v4.4.3
with:
# TODO: Replace `MyProject` with the correct project name.
name: MyProject
path: install
path: build/*.tar.gz
if-no-files-found: error
overwrite: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
!.git*

build
install
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ if(MY_PROJECT_ENABLE_INSTALL)
${CMAKE_CURRENT_BINARY_DIR}/cmake/MyProjectConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/MyProjectConfigVersion.cmake
DESTINATION lib/cmake/MyProject)

set(CPACK_SYSTEM_NAME any)
include(CPack)
endif()
11 changes: 9 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 3,
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21
"minor": 25
},
"configurePresets": [
{
Expand All @@ -28,5 +28,12 @@
"noTestsAction": "error"
}
}
],
"packagePresets": [
{
"name": "default",
"configurePreset": "default",
"generators": ["TGZ"]
}
]
}
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Do the following steps to replace all the sample information from the template w
- Modify to install the correct files to the correct destination.
- Modify the [`CMakePresets.json`](./CMakePresets.json) file as follows:
- Rename the options to be prefixed with the correct project name.
- Modify workflow files as follows:
- Use the correct project name in the [`build.yaml`](./.github/workflows/build.yaml) workflow file.

> Note: You can also search for the `TODO` comments for a list of information that needs to be replaced.
Expand Down Expand Up @@ -77,10 +75,10 @@ ctest --preset development

### Cut a Release

When everything is complete, run the following command to install the new project to the `install` directory:
When everything is complete, run the following command to package the project:

```sh
cmake --install build --prefix install
cpack --preset default
```

Files inside the `install` directory can be included in the release files. Before releasing, ensure that this project is at the correct version and pushed to the upstream repository. Refer to [this documentation](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) for more information about releasing a project.
The project will be packaged into the `build/*.tar.gz` file, which can be included in the release files. Before releasing, ensure that this project is at the correct version and has been pushed to the upstream repository. Refer to [this documentation](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) for more information about releasing a project.

0 comments on commit b53f96a

Please sign in to comment.