Skip to content
Closed
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
125 changes: 124 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

permissions:
contents: read
contents: write
checks: write
pull-requests: write

Expand Down Expand Up @@ -256,3 +256,126 @@ jobs:
- name: Publish to Job Summary
shell: bash
run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY"

# ---------------------------------------------------------------------------
# Package: build .deb and .rpm via CPack
# ---------------------------------------------------------------------------
package:
name: Package (DEB + RPM)
needs: build-test-docs
runs-on: ubuntu-22.04
env:
CARGO_TERM_COLOR: always
CMAKE_BUILD_PARALLEL_LEVEL: 2
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install system dependencies
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
ninja-build \
pkg-config \
rpm

- name: Set up Rust (stable)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Cache cargo + build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
tempoch/target
tempoch/tempoch-ffi/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Configure (CMake, Release)
shell: bash
run: |
set -euo pipefail
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DTEMPOCH_BUILD_DOCS=OFF

- name: Build
shell: bash
run: cmake --build build --target test_tempoch

- name: Install to staging prefix
shell: bash
run: cmake --install build --prefix build/staging

- name: Copy shared libraries to staging
shell: bash
run: |
set -euo pipefail
mkdir -p build/staging/lib
cp tempoch/tempoch-ffi/target/release/libtempoch_ffi.so \
build/staging/lib/ || true

- name: Generate packages (CPack)
shell: bash
run: |
set -euo pipefail
cd build
cpack --config CPackConfig.cmake -G "DEB;RPM" -B packages
ls -lh packages/

- name: Upload DEB package
uses: actions/upload-artifact@v4
with:
name: tempoch-cpp-deb
path: build/packages/*.deb
retention-days: 30

- name: Upload RPM package
uses: actions/upload-artifact@v4
with:
name: tempoch-cpp-rpm
path: build/packages/*.rpm
retention-days: 30

# ---------------------------------------------------------------------------
# Release: create GitHub Release and attach packages (tag pushes only)
# ---------------------------------------------------------------------------
release:
name: GitHub Release
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Download DEB artifact
uses: actions/download-artifact@v4
with:
name: tempoch-cpp-deb
path: dist/

- name: Download RPM artifact
uses: actions/download-artifact@v4
with:
name: tempoch-cpp-rpm
path: dist/

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,36 @@ install(EXPORT tempoch_cppTargets
NAMESPACE tempoch::
DESTINATION lib/cmake/tempoch_cpp
)

# ---------------------------------------------------------------------------
# Packaging (CPack — DEB and RPM)
# ---------------------------------------------------------------------------
set(CPACK_PACKAGE_NAME "tempoch-cpp")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Siderust")
set(CPACK_PACKAGE_CONTACT "VPRamon <vallespuigramon@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"C++ wrapper for the tempoch astronomical time library")
set(CPACK_PACKAGE_DESCRIPTION
"tempoch-cpp provides a header-only C++17 API over the tempoch Rust\n"
"time library via the tempoch-ffi C ABI. It bundles the pre-built\n"
"shared library (tempoch_ffi) together with the C++ headers and CMake\n"
"package config.")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/Siderust/tempoch-cpp")

# -- DEB -----------------------------------------------------------------------
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPRamon <vallespuigramon@gmail.com>")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.17), libstdc++6 (>= 9)")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

# -- RPM -----------------------------------------------------------------------
set(CPACK_RPM_PACKAGE_LICENSE "AGPL-3.0")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.17, libstdc++ >= 9")
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)

set(CPACK_GENERATOR "DEB;RPM")

include(CPack)
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,60 @@ find_package(tempoch_cpp REQUIRED)
target_link_libraries(your_target PRIVATE tempoch::tempoch_cpp)
```

## Deployment

Packages for Debian/Ubuntu (`.deb`) and RHEL/Fedora/openSUSE (`.rpm`) are built
with CPack.

### Prerequisites

```bash
# Debian/Ubuntu
sudo apt-get install cmake ninja-build rpm

# RHEL/Fedora
sudo dnf install cmake ninja-build dpkg
```

### Build the packages

```bash
git clone --recurse-submodules <repo-url>
cd tempoch-cpp

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DTEMPOCH_BUILD_DOCS=OFF
cmake --build build --parallel

# Install headers + cmake config to a staging prefix
cmake --install build --prefix build/staging

# Generate .deb and .rpm in build/packages/
cd build
cpack --config CPackConfig.cmake -G "DEB;RPM" -B packages
ls packages/
```

### Install on the target system

```bash
# Debian/Ubuntu
sudo dpkg -i packages/tempoch-cpp-*.deb

# RHEL/Fedora/openSUSE
sudo rpm -i packages/tempoch-cpp-*.rpm
```

After installation, headers land in `/usr/local/include/tempoch/` and the
shared library in `/usr/local/lib/`. CMake consumers can then use:

```cmake
find_package(tempoch_cpp REQUIRED)
target_link_libraries(your_target PRIVATE tempoch::tempoch_cpp)
```

> **Note:** Pre-built `.deb` and `.rpm` packages are also automatically attached
> to every [GitHub Release](https://github.com/Siderust/tempoch-cpp/releases).

## License

This repository wraps the upstream `tempoch` project (git submodule in `tempoch/`). See `tempoch/LICENSE` for licensing details.
2 changes: 1 addition & 1 deletion qtty-cpp
2 changes: 1 addition & 1 deletion tempoch
Loading