Skip to content

Commit 21d8e40

Browse files
authored
Create distribution packages for ubuntu (.deb release v0.0.1) (#129)
* Github workflow for Ubuntu Packaging * Github workflow for Ubuntu Packaging. * Github workflow for Ubuntu Packaging! * Refactor packaging workflow based on the feedback * Fix CPack versioning: derive major/minor/patch from INFLECTION_VERSION * Fixing Version Issue * Fixing the Cmake Version * Fix: Cpack Version Handling * Add CPack-based Ubuntu packaging and GitHub Actions release workflow
1 parent 23cc5bb commit 21d8e40

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ----------------------------------------------------------------------------------------
2+
# To update ICU version:
3+
# 1. Update the ICU_VERSION environment variable below.
4+
# 2. Check the ICU binary URL — is the filename still Ubuntu22.04-x64.tgz?
5+
# (e.g., icu4c-78_1-Ubuntu22.04-x64.tgz)
6+
# 3. Update inflection/CMakeLists.txt:
7+
# - Modify `CPACK_DEBIAN_PACKAGE_DEPENDS` to match the new ICU version.
8+
# ----------------------------------------------------------------------------------------
9+
10+
name: Build & Package (Ubuntu)
11+
12+
on:
13+
push:
14+
tags:
15+
- 'v*'
16+
workflow_dispatch:
17+
18+
jobs:
19+
build-and-package:
20+
runs-on: ubuntu-latest
21+
env:
22+
ICU_VERSION: 77_1
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
lfs: true
28+
29+
- name: Setup Git LFS
30+
run: |
31+
git lfs install
32+
git lfs pull
33+
34+
- name: Install system dependencies
35+
run: |
36+
sudo apt update
37+
sudo apt install -y cmake build-essential clang pkg-config
38+
39+
- name: Cache ICU
40+
uses: actions/cache@v4
41+
id: cache-icu
42+
with:
43+
path: /usr/local
44+
key: icu-${{ env.ICU_VERSION }}-ubuntu-${{ runner.os }}
45+
46+
- name: Install ICU (Binary)
47+
if: steps.cache-icu.outputs.cache-hit != 'true'
48+
run: |
49+
cd /tmp
50+
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION//_/-}/icu4c-${ICU_VERSION}-Ubuntu22.04-x64.tgz
51+
mkdir icu-install
52+
tar -xzf icu4c-${ICU_VERSION}-Ubuntu22.04-x64.tgz -C icu-install
53+
sudo cp -r icu-install/icu/usr/local/* /usr/local/
54+
sudo ldconfig
55+
56+
- name: Setup ICU (from cache)
57+
if: steps.cache-icu.outputs.cache-hit == 'true'
58+
run: |
59+
sudo ldconfig
60+
61+
- name: Configure & Build
62+
run: |
63+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
64+
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
65+
mkdir -p inflection/build
66+
cd inflection/build
67+
CC=clang CXX=clang++ cmake .. \
68+
-DCMAKE_BUILD_TYPE=Release \
69+
-DICU_ROOT=/usr/local \
70+
-DCMAKE_PREFIX_PATH=/usr/local
71+
make -j$(nproc)
72+
73+
- name: Run tests
74+
run: |
75+
cd inflection/build
76+
make -j$(nproc) check
77+
78+
- name: Package with CPack
79+
run: |
80+
cd inflection/build
81+
cpack
82+
ls -la *.deb *.tar.gz
83+
84+
- name: Upload release artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: ubuntu-release-artifacts
88+
path: |
89+
inflection/build/*.deb
90+
inflection/build/*.tar.gz
91+
retention-days: 30
92+
93+
- name: Upload to GitHub Release
94+
uses: softprops/action-gh-release@v2
95+
if: startsWith(github.ref, 'refs/tags/')
96+
with:
97+
name: "Release ${{ github.ref_name }}"
98+
files: |
99+
inflection/build/*.deb
100+
inflection/build/*.tar.gz
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+

inflection/CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,51 @@ make generate-coverage-csv : Generates code coverage as a csv\\n\
131131
install(TARGETS inflection LIBRARY COMPONENT inflection_library)
132132
install(DIRECTORY ${INFLECTION_INCLUDE_ROOT}/ TYPE INCLUDE COMPONENT inflection_headers)
133133
install(DIRECTORY ${INFLECTION_DATA_ROOT}/ TYPE DATA COMPONENT inflection_data)
134+
135+
136+
137+
# CPack Configuration for Ubuntu Packaging
138+
139+
set(CPACK_PACKAGE_NAME "unicode-inflection")
140+
141+
# Apply the current tagged Inflection version to the CPack version.
142+
# CPack may inherit a default or cached version, so we explicitly set it here.
143+
set(CPACK_PACKAGE_VERSION "${INFLECTION_VERSION}")
144+
145+
string(REPLACE "." ";" INFLECTION_VERSION_LIST "${INFLECTION_VERSION}")
146+
147+
# Set defaults to avoid list index errors
148+
set(CPACK_PACKAGE_VERSION_MAJOR "0")
149+
set(CPACK_PACKAGE_VERSION_MINOR "0")
150+
set(CPACK_PACKAGE_VERSION_PATCH "0")
151+
152+
list(LENGTH INFLECTION_VERSION_LIST _len)
153+
if(_len GREATER 0)
154+
list(GET INFLECTION_VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR)
155+
endif()
156+
if(_len GREATER 1)
157+
list(GET INFLECTION_VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR)
158+
endif()
159+
if(_len GREATER 2)
160+
list(GET INFLECTION_VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
161+
endif()
162+
163+
set(CPACK_PACKAGE_VENDOR "Unicode Consortium")
164+
set(CPACK_PACKAGE_CONTACT "https://github.com/unicode-org/inflection")
165+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unicode Inflection Library")
166+
set(CPACK_GENERATOR "DEB;TGZ")
167+
168+
# DEB-specific options
169+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unicode Consortium <[email protected]>")
170+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libicu77 (>= 77.1)")
171+
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
172+
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
173+
set(CPACK_DEBIAN_PACKAGE_VERSION "${INFLECTION_VERSION}")
174+
175+
# Source package
176+
set(CPACK_SOURCE_GENERATOR "TGZ")
177+
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;/.vscode/;/.idea/")
178+
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${INFLECTION_VERSION}")
179+
180+
include(CPack)
181+

0 commit comments

Comments
 (0)