From 597b2431dd39703b17e2a0be7cb89f9e880d3622 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 13:11:11 +0100 Subject: [PATCH 01/19] Use WORKDIR to simplify Dockerfile --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e811e2..884b09d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,9 +25,8 @@ 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 From 6db1afac239a2fac236c5280675f5108610fe28a Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 13:11:24 +0100 Subject: [PATCH 02/19] Add Docker stage to build release artifacts --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Dockerfile b/Dockerfile index 884b09d..0a8312f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,11 +21,25 @@ WORKDIR /home/blinky/ +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 WORKDIR /tmp/util_caching/build + RUN cmake .. && \ cmake --build . && \ cmake --install . && \ From ea6d843273a374b1503a3afd513a712d453c59b1 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 13:19:50 +0100 Subject: [PATCH 03/19] Add Docker stage to run unit tests --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0a8312f..5fb095b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,18 @@ 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 From f097f8174ffcb9f49639f194af8b833a31a9ee72 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 13:29:59 +0100 Subject: [PATCH 04/19] Add workflow to run unit tests --- .github/workflows/run-unit-tests.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/run-unit-tests.yaml 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 + From 1cd81c6e3afb2a2c16bfa67bfeee32ff23288607 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 13:38:54 +0100 Subject: [PATCH 05/19] Create action to create a release --- .github/workflows/create-release.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/create-release.yaml diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 0000000..5e57227 --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,26 @@ +name: Create Release +on: + push: + tags: + - "v*" + +jobs: + build-and-release: + permissions: + contents: write + + runs-on: ubuntu-latest + steps: + - name: Build release packages + uses: docker/build-push-action@v6 + with: + outputs: | + type=local,dest=/tmp/artifacts + push: false + target: release + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "/tmp/artifacts/release/*" + From 37f6cbf91160b0b13f50bf1773249781e49e0353 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 15:24:24 +0100 Subject: [PATCH 06/19] Add workflow to auto-bump the version --- .github/workflows/bump-version.yaml | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/bump-version.yaml diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml new file mode 100644 index 0000000..ddb2b71 --- /dev/null +++ b/.github/workflows/bump-version.yaml @@ -0,0 +1,50 @@ +name: Bump version +on: + pull_request: + types: + - closed + branches: + - main + - github_action # TODO: Remove before merge + +jobs: + build: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + 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=$(cat version | cut -d'v' -f2) + 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: patch + 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 }} From 2baee09becca1e515d7b741751246815d08f8617 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 16:04:34 +0100 Subject: [PATCH 07/19] Copy release artifacts differently due to deadlock when using outputs See https://github.com/moby/buildkit/issues/2950 --- .github/workflows/create-release.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 5e57227..e7a76f1 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -14,11 +14,16 @@ jobs: - name: Build release packages uses: docker/build-push-action@v6 with: - outputs: | - type=local,dest=/tmp/artifacts + tags: | + util_caching_release push: false 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: From 148b9d17c5bc63d74b8844acc2d4c1391b2776e2 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 16:27:46 +0100 Subject: [PATCH 08/19] Combine version bump and release workflows An action using the GITHUB_TOKEN cannot trigger another workflow. So to create a new release after a version bump, we simply run the release in the same workflow. See https://github.com/orgs/community/discussions/27028#discussioncomment-3254360 --- ...l => bump-version-and-create-release.yaml} | 33 +++++++++++++++++-- .github/workflows/create-release.yaml | 31 ----------------- 2 files changed, 31 insertions(+), 33 deletions(-) rename .github/workflows/{bump-version.yaml => bump-version-and-create-release.yaml} (66%) delete mode 100644 .github/workflows/create-release.yaml diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version-and-create-release.yaml similarity index 66% rename from .github/workflows/bump-version.yaml rename to .github/workflows/bump-version-and-create-release.yaml index ddb2b71..ab523a2 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -1,4 +1,4 @@ -name: Bump version +name: Bump version and create release on: pull_request: types: @@ -8,11 +8,13 @@ on: - github_action # TODO: Remove before merge jobs: - build: + 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 @@ -48,3 +50,30 @@ jobs: 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: Build release packages + uses: docker/build-push-action@v6 + with: + tags: | + util_caching_release + push: false + 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 }} + + diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml deleted file mode 100644 index e7a76f1..0000000 --- a/.github/workflows/create-release.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Create Release -on: - push: - tags: - - "v*" - -jobs: - build-and-release: - permissions: - contents: write - - runs-on: ubuntu-latest - steps: - - name: Build release packages - uses: docker/build-push-action@v6 - with: - tags: | - util_caching_release - push: false - 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/*" - From 636940cdbfc084b35f7856489ece1db67af01c08 Mon Sep 17 00:00:00 2001 From: ll-nick <68419636+ll-nick@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:44:57 +0100 Subject: [PATCH 09/19] Set VERSION env in a more reuseable manner Co-authored-by: Piotr Spieker --- .github/workflows/bump-version-and-create-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index ab523a2..184a83b 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -22,7 +22,7 @@ jobs: - name: Read version from file run: | # Read the version from the version file, only store the number (without the 'v') - INITIAL_VERSION=$(cat version | cut -d'v' -f2) + INITIAL_VERSION=$(source version && echo ${VERSION#v}) echo "Current version: $INITIAL_VERSION" echo "INITIAL_VERSION=${INITIAL_VERSION}" >> $GITHUB_ENV From b7d01bec607f1b8097a77a1ad62da8f90dca8917 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 09:49:53 +0100 Subject: [PATCH 10/19] Add note about deb package in README install section --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4028985..a73b166 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 from the [releases page](https://github.com/KIT-MRT/util_caching/releases) and install it with `dpkg`: + +```bash +sudo dpkg -i util-caching*.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. From c1486dfd8471528061ffeafcbb12363596e43d73 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 09:52:48 +0100 Subject: [PATCH 11/19] Set default version bump to minor --- .github/workflows/bump-version-and-create-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index 184a83b..5d0cbfb 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -30,7 +30,7 @@ jobs: id: bump_version uses: anothrNick/github-tag-action@v1 env: - DEFAULT_BUMP: patch + DEFAULT_BUMP: minor DRY_RUN: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} INITIAL_VERSION: ${{ env.INITIAL_VERSION }} From 5adc18d4d23ede5456aca6d471f2fd2d45139c00 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 09:54:26 +0100 Subject: [PATCH 12/19] Explicitly checkout new tag before running release build --- .github/workflows/bump-version-and-create-release.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index 5d0cbfb..4642596 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -57,6 +57,11 @@ jobs: 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: From 93676b754abc939fd8a3ad6db852182df4216401 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 10:10:59 +0100 Subject: [PATCH 13/19] Add the PR description as release body --- .github/workflows/bump-version-and-create-release.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index 4642596..aabdd65 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -62,6 +62,10 @@ jobs: with: ref: ${{ needs.bump-version.outputs.new_tag }} + - name: Save Pull Request Description to File + run: | + echo "${{ github.event.pull_request.body }}" > /tmp/pull_request_description.md + - name: Build release packages uses: docker/build-push-action@v6 with: @@ -80,5 +84,5 @@ jobs: with: artifacts: "/tmp/artifacts/release/*" tag: ${{ needs.bump-version.outputs.new_tag }} - + bodyFile: /tmp/pull_request_description.md From 45d3b44dc25d5ba8df5b117f5e2c84f06321ac37 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 10:31:55 +0100 Subject: [PATCH 14/19] Set context to fix git context limitation of docker build action --- .github/workflows/bump-version-and-create-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index aabdd65..07c38d8 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -69,9 +69,10 @@ jobs: - name: Build release packages uses: docker/build-push-action@v6 with: + context: . + push: false tags: | util_caching_release - push: false target: release - name: Copy release packages From 6e22a2ec7929d454f9ec7d323707c32424f0ed4d Mon Sep 17 00:00:00 2001 From: Piotr Spieker Date: Mon, 11 Nov 2024 12:13:24 +0100 Subject: [PATCH 15/19] Update CMake project description following the Readme change in 8d8b643 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ) From c0e3685381852542266e27dbdb19633c0e001d4b Mon Sep 17 00:00:00 2001 From: ll-nick <68419636+ll-nick@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:11:08 +0100 Subject: [PATCH 16/19] Apply suggestions from code review Simplify the way the release body is defined. Co-authored-by: Piotr Spieker --- .github/workflows/bump-version-and-create-release.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index 07c38d8..e171660 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -62,10 +62,6 @@ jobs: with: ref: ${{ needs.bump-version.outputs.new_tag }} - - name: Save Pull Request Description to File - run: | - echo "${{ github.event.pull_request.body }}" > /tmp/pull_request_description.md - - name: Build release packages uses: docker/build-push-action@v6 with: @@ -85,5 +81,5 @@ jobs: with: artifacts: "/tmp/artifacts/release/*" tag: ${{ needs.bump-version.outputs.new_tag }} - bodyFile: /tmp/pull_request_description.md + body: ${{ github.event.pull_request.body }} From 71e4eaffa42f58ec680541a052a2b36abda4a8a2 Mon Sep 17 00:00:00 2001 From: Piotr Spieker Date: Mon, 11 Nov 2024 13:37:56 +0100 Subject: [PATCH 17/19] Rename debian package to libutil-caching-dev --- cmake/cpack_config.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake index 13f6177..cce1787 100644 --- a/cmake/cpack_config.cmake +++ b/cmake/cpack_config.cmake @@ -15,6 +15,7 @@ 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) @@ -26,6 +27,3 @@ set(CPACK_DEBIAN_PACKAGE_SECTION "libdevel") set(CPACK_DEBIAN_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 From 3407cddfddf64c7635f10aad7c0b51a979f8aeb7 Mon Sep 17 00:00:00 2001 From: Piotr Spieker Date: Mon, 11 Nov 2024 13:39:58 +0100 Subject: [PATCH 18/19] Use fixed name for debian package file (without version) --- README.md | 4 ++-- cmake/cpack_config.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a73b166..d1b37b3 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,10 @@ More usage please check the unittest. ### Using Debian package (recommended) We provide a Debian package for easy installation on Debian-based distributions. -Download the latest `.deb` package from the [releases page](https://github.com/KIT-MRT/util_caching/releases) and install it with `dpkg`: +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 util-caching*.deb +sudo dpkg -i libutil-caching-dev.deb ``` ### Using Docker image diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake index cce1787..d7516c6 100644 --- a/cmake/cpack_config.cmake +++ b/cmake/cpack_config.cmake @@ -17,7 +17,7 @@ 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) From 833222e9274a153bb0017f565feac4feca1ec7ab Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 14:00:12 +0100 Subject: [PATCH 19/19] Remove dev branch from workflow triggers --- .github/workflows/bump-version-and-create-release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index e171660..524b4ee 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -5,7 +5,6 @@ on: - closed branches: - main - - github_action # TODO: Remove before merge jobs: bump-version: