Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub action #21

Merged
merged 19 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/bump-version-and-create-release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

22 changes: 22 additions & 0 deletions .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
31 changes: 28 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
See [demo/README.md](demo/README.md) for how to run the demo, showcasing the use of `util_caching` in a ROS node.
6 changes: 2 additions & 4 deletions cmake/cpack_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Loading