diff --git a/.github/workflows/create-ubuntu-distribution-packaging.yml b/.github/workflows/create-ubuntu-distribution-packaging.yml new file mode 100644 index 00000000..837bbfcb --- /dev/null +++ b/.github/workflows/create-ubuntu-distribution-packaging.yml @@ -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) + +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 }} + diff --git a/inflection/CMakeLists.txt b/inflection/CMakeLists.txt index bc82e65c..0b8ac4ae 100644 --- a/inflection/CMakeLists.txt +++ b/inflection/CMakeLists.txt @@ -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}") + +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 ") +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) +