Skip to content

Create distribution packages for ubuntu (.deb release v0.0.1) #129

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

Merged
merged 9 commits into from
Jul 14, 2025
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
103 changes: 103 additions & 0 deletions .github/workflows/create-ubuntu-distribution-packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# ----------------------------------------------------------------------------------------
# To update ICU version:
# 1. Update the ICU_VERSION environment variable below.
# 2. Check the ICU binary URL — is the filename still Ubuntu22.04-x64.tgz?
# (e.g., icu4c-78_1-Ubuntu22.04-x64.tgz)
# 3. Update inflection/CMakeLists.txt:
# - Modify `CPACK_DEBIAN_PACKAGE_DEPENDS` to match the new ICU version.
# ----------------------------------------------------------------------------------------

name: Build & Package (Ubuntu)
Copy link
Contributor

@nciric nciric Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a comment on top (or a separate document) that tells us how to update ICU dependancy:

# To update ICU version:
# 1. Update ICU_VERSION variable
# 2. Check package names, e.g. is it still Ubuntu22.04-
# 3. Update inflection/CMakeLists.txt where we check CPACK_DEBIAN_PACKAGE_DEPENDS "libicu77 (>= 77.1)"

Anything else I missed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will do that.


on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
build-and-package:
runs-on: ubuntu-latest
env:
ICU_VERSION: 77_1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true

- name: Setup Git LFS
run: |
git lfs install
git lfs pull

- name: Install system dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential clang pkg-config

- name: Cache ICU
uses: actions/cache@v4
id: cache-icu
with:
path: /usr/local
key: icu-${{ env.ICU_VERSION }}-ubuntu-${{ runner.os }}

- name: Install ICU (Binary)
if: steps.cache-icu.outputs.cache-hit != 'true'
run: |
cd /tmp
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION//_/-}/icu4c-${ICU_VERSION}-Ubuntu22.04-x64.tgz
mkdir icu-install
tar -xzf icu4c-${ICU_VERSION}-Ubuntu22.04-x64.tgz -C icu-install
sudo cp -r icu-install/icu/usr/local/* /usr/local/
sudo ldconfig

- name: Setup ICU (from cache)
if: steps.cache-icu.outputs.cache-hit == 'true'
run: |
sudo ldconfig

- name: Configure & Build
run: |
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
mkdir -p inflection/build
cd inflection/build
CC=clang CXX=clang++ cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DICU_ROOT=/usr/local \
-DCMAKE_PREFIX_PATH=/usr/local
make -j$(nproc)

- name: Run tests
run: |
cd inflection/build
make -j$(nproc) check

- name: Package with CPack
run: |
cd inflection/build
cpack
ls -la *.deb *.tar.gz

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: ubuntu-release-artifacts
path: |
inflection/build/*.deb
inflection/build/*.tar.gz
retention-days: 30

- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: "Release ${{ github.ref_name }}"
files: |
inflection/build/*.deb
inflection/build/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

48 changes: 48 additions & 0 deletions inflection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,51 @@ make generate-coverage-csv : Generates code coverage as a csv\\n\
install(TARGETS inflection LIBRARY COMPONENT inflection_library)
install(DIRECTORY ${INFLECTION_INCLUDE_ROOT}/ TYPE INCLUDE COMPONENT inflection_headers)
install(DIRECTORY ${INFLECTION_DATA_ROOT}/ TYPE DATA COMPONENT inflection_data)



# CPack Configuration for Ubuntu Packaging

set(CPACK_PACKAGE_NAME "unicode-inflection")

# Apply the current tagged Inflection version to the CPack version.
# CPack may inherit a default or cached version, so we explicitly set it here.
set(CPACK_PACKAGE_VERSION "${INFLECTION_VERSION}")

Copy link
Contributor

@nciric nciric Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put a comment here:

# Apply the current tagged Inflection version to the CPack version.
# CPack inherits the version from ??? so we need to reset before the assignment.

string(REPLACE "." ";" INFLECTION_VERSION_LIST "${INFLECTION_VERSION}")

# Set defaults to avoid list index errors
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")

list(LENGTH INFLECTION_VERSION_LIST _len)
if(_len GREATER 0)
list(GET INFLECTION_VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR)
endif()
if(_len GREATER 1)
list(GET INFLECTION_VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR)
endif()
if(_len GREATER 2)
list(GET INFLECTION_VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
endif()

set(CPACK_PACKAGE_VENDOR "Unicode Consortium")
set(CPACK_PACKAGE_CONTACT "https://github.com/unicode-org/inflection")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unicode Inflection Library")
set(CPACK_GENERATOR "DEB;TGZ")

# DEB-specific options
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unicode Consortium <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libicu77 (>= 77.1)")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_VERSION "${INFLECTION_VERSION}")

# Source package
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;/.vscode/;/.idea/")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${INFLECTION_VERSION}")

include(CPack)

Loading