diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml new file mode 100644 index 0000000..524b4ee --- /dev/null +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -0,0 +1,84 @@ +name: Bump version and create release +on: + pull_request: + types: + - closed + branches: + - main + +jobs: + bump-version: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + new_tag: ${{ steps.bump_version.outputs.new_tag }} + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Read version from file + run: | + # Read the version from the version file, only store the number (without the 'v') + INITIAL_VERSION=$(source version && echo ${VERSION#v}) + echo "Current version: $INITIAL_VERSION" + echo "INITIAL_VERSION=${INITIAL_VERSION}" >> $GITHUB_ENV + + - name: Bump version and push tag + id: bump_version + uses: anothrNick/github-tag-action@v1 + env: + DEFAULT_BUMP: minor + DRY_RUN: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INITIAL_VERSION: ${{ env.INITIAL_VERSION }} + WITH_V: true + + - name: Update version file with new version + run: | + echo "New version: ${{ steps.bump_version.outputs.new_tag }}" + echo "VERSION=${{ steps.bump_version.outputs.new_tag }}" > version + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git add version + git commit -m "chore: update version file to ${{ steps.bump_version.outputs.new_tag }}" + git push + + - name: Push new tag + run: | + git tag ${{ steps.bump_version.outputs.new_tag }} + git push origin ${{ steps.bump_version.outputs.new_tag }} + + create-release: + needs: bump-version + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repository and pull the new tag + uses: actions/checkout@v4 + with: + ref: ${{ needs.bump-version.outputs.new_tag }} + + - name: Build release packages + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: | + util_caching_release + target: release + + - name: Copy release packages + run: | + mkdir -p /tmp/artifacts/ + docker run --rm -v /tmp/artifacts:/tmp/artifacts util_caching_release cp -r /release /tmp/artifacts/ + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "/tmp/artifacts/release/*" + tag: ${{ needs.bump-version.outputs.new_tag }} + body: ${{ github.event.pull_request.body }} + diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml new file mode 100644 index 0000000..f9cce27 --- /dev/null +++ b/.github/workflows/run-unit-tests.yaml @@ -0,0 +1,22 @@ +name: Run unit tests + +on: + push: + +jobs: + build-and-run-unit-tests: + runs-on: ubuntu-latest + + steps: + - name: Build core library unit test Docker image + uses: docker/build-push-action@v6 + with: + push: false + tags: | + ghcr.io/kit-mrt/util_caching_tests + target: unit_test + + - name: Run library unit tests + run: | + docker run --rm ghcr.io/kit-mrt/util_caching_tests + diff --git a/CMakeLists.txt b/CMakeLists.txt index 2df3a70..c3f3d35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(PACKAGE_VERSION ${CMAKE_MATCH_1}) # Setup project project(util_caching VERSION ${PACKAGE_VERSION} - DESCRIPTION "This package caches arbitrary values, which can be recalled by specifying a key." + DESCRIPTION "This packages provides a utility class to simplify caching of arbitrary values." LANGUAGES CXX ) diff --git a/Dockerfile b/Dockerfile index 6e811e2..5fb095b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,13 +21,38 @@ WORKDIR /home/blinky/ +FROM base AS unit_test + +COPY . /tmp/util_caching +WORKDIR /tmp/util_caching/build + +RUN cmake -DBUILD_TESTS=true .. && \ + cmake --build . -j9 + +CMD ["cmake", "--build", ".", "--target", "test"] + + + +FROM base AS release + +COPY . /tmp/util_caching +WORKDIR /tmp/util_caching/build + +RUN cmake .. && \ + cmake --build . && \ + cmake --build . --target package && \ + mv packages /release && \ + rm -rf /tmp/util_caching + + + FROM base AS install # Install util_caching COPY . /tmp/util_caching -RUN mkdir /tmp/util_caching/build && \ - cd /tmp/util_caching/build && \ - cmake .. && \ +WORKDIR /tmp/util_caching/build + +RUN cmake .. && \ cmake --build . && \ cmake --install . && \ rm -rf /tmp/util_caching diff --git a/README.md b/README.md index 4028985..d1b37b3 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,15 @@ More usage please check the unittest. ## Installation +### Using Debian package (recommended) + +We provide a Debian package for easy installation on Debian-based distributions. +Download the [latest `.deb` package](https://github.com/KIT-MRT/util_caching/releases/latest/download/libutil-caching-dev.deb) and install it with `dpkg`: + +```bash +sudo dpkg -i libutil-caching-dev.deb +``` + ### Using Docker image We provide a [`Dockerfile`](./Dockerfile) with the library already installed globally. @@ -158,4 +167,4 @@ docker compose -f demo/docker-compose.ros.yaml build docker compose -f demo/docker-compose.ros.yaml run --rm util_caching_ros ``` -See [demo/README.md](demo/README.md) for how to run the demo, showcasing the use of `util_caching` in a ROS node. \ No newline at end of file +See [demo/README.md](demo/README.md) for how to run the demo, showcasing the use of `util_caching` in a ROS node. diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake index 70eef0d..d1e526c 100644 --- a/cmake/cpack_config.cmake +++ b/cmake/cpack_config.cmake @@ -15,8 +15,9 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_GENERATOR "TGZ;ZIP;DEB") +set(CPACK_DEBIAN_PACKAGE_NAME "libutil-caching-dev") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}") -set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}.deb") set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) set(CPACK_DEB_COMPONENT_INSTALL YES) @@ -26,6 +27,3 @@ set(CPACK_DEBIAN_PACKAGE_SECTION "libdevel") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") set(CPACK_DEBIAN_PACKAGE_DEPENDS "") - -# Rename package to kebab case -set(CPACK_DEBIAN_PACKAGE_NAME "util-caching") \ No newline at end of file