Skip to content

Commit

Permalink
build: package with CPack
Browse files Browse the repository at this point in the history
Such packages can be used by consumers and potentially in our CI. We directly
create a new CI job for that. It creates a Debian package and a simple tar
archive.
  • Loading branch information
romangg committed Feb 22, 2024
1 parent fded30c commit fe3ecaf
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ jobs:
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master

package:
uses: ./.github/workflows/package.yml
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master
package-name: theseus-ship
70 changes: 70 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Package
on:
workflow_call:
inputs:
image:
description: Image to package on
required: true
type: string
artifact-name:
description: Artifact name of build dir
required: false
type: string
default: 'build'
package-name:
description: Name of the resulting packages
required: true
type: string

jobs:
deb:
name: Create deb
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Install dpkg
run: pacman -Sy --needed --quiet --noconfirm dpkg
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
- name: Untar artifact
run: tar -xzf build-dir.tar
- name: Run CPack
run: cd build && cpack -G DEB -D CPACK_DEBIAN_FILE_NAME=${{ inputs.package-name }}.deb
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deb-package
path: build/_CPack_Packages/Linux/DEB/${{ inputs.package-name }}.deb
retention-days: 8

tar:
name: Create tar
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
- name: Untar artifact
run: tar -xzf build-dir.tar
- name: Run CPack
# Need to use CPACK_PACKAGE_FILE_NAME instead of CPACK_ARCHIVE_FILE_NAME
# See: https://gitlab.kitware.com/cmake/cmake/-/issues/20419
run: cd build && cpack -G TGZ -D CPACK_PACKAGE_FILE_NAME=${{ inputs.package-name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tar-package
path: build/_CPack_Packages/Linux/TGZ/${{ inputs.package-name }}.tar.gz
retention-days: 8
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,5 @@ install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/kwin_wayland_wrapper
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
)

include(Packing)
21 changes: 21 additions & 0 deletions cmake/modules/Packing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: GPL-2.0-or-later

set(CPACK_PACKAGE_NAME theseus-ship CACHE STRING "Deb package name")
set(CPACK_PACKAGE_VENDOR "WinFT")

set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Roman Gilg")

set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

include(CPack)

0 comments on commit fe3ecaf

Please sign in to comment.