Skip to content

Commit

Permalink
Build binary packages for every push, more flexible name for packages
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1701c committed Oct 13, 2024
1 parent 4262f75 commit 8d85879
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,21 @@ jobs:
submodules: true
fetch-depth: 0

- name: Get defined project version
shell: bash
run: echo project_version=$(sed -nr 's/set\(CMAKE_PROJECT_VERSION "(.+)"\)/\1/p' CMakeLists.txt) >> $GITHUB_ENV

- name: Update Version in CMakeLists
if: inputs.publish-version
shell: bash
run: |
publish_version="${{ inputs.publish-version }}"
cmake_version=$(sed -nr 's/set\(CMAKE_PROJECT_VERSION "(.+)"\)/\1/p' CMakeLists.txt)
if ! [[ $publish_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format for publish-version: $publish_version. It must be in the format x.y.z."
exit 1
fi
if [ "$(printf "%s\n%s" "$cmake_version" "$publish_version" | sort -V | head -n1)" != "$cmake_version" ] || [ "$cmake_version" == "$publish_version" ]; then
echo "CMake version $cmake_version is not smaller than publish-version $publish_version."
if [ "$(printf "%s\n%s" "${{ env.project_version }}" "$publish_version" | sort -V | head -n1)" != "${{ env.project_version }}" ] || [ "${{ env.project_version }}" == "$publish_version" ]; then
echo "CMake version ${{ env.project_version }} is not smaller than publish-version $publish_version."
exit 1
fi
sed -i -E "s/(set\s*\(\s*CMAKE_PROJECT_VERSION\s*\")[0-9]+\.[0-9]+\.[0-9]+(\")/\1${publish_version}\2/" CMakeLists.txt
Expand All @@ -97,14 +100,10 @@ jobs:
run: mkdir -p build

- name: Build and install
id: build
working-directory: build/
shell: bash
run: |
CMAKE_ARGS=".. -DCMAKE_BUILD_TYPE=Release"
if [[ -n "${{ inputs.publish-version }}" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DCPACK_OS=${{ matrix.os.name }}"
fi
CMAKE_ARGS=".. -DCMAKE_BUILD_TYPE=Release -DCPACK_OS=${{ matrix.os.name }}"
if [[ "${{ matrix.plasma_version }}" == "plasma6" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DBUILD_WITH_QT6=ON"
else
Expand Down Expand Up @@ -148,12 +147,13 @@ jobs:
- name: Update Version in CMakeLists
run: |
sed -i -E "s/(set\s*\(\s*CMAKE_PROJECT_VERSION\s*\")[0-9]+\.[0-9]+\.[0-9]+(\")/\1${{ inputs.publish-version }}\2/" CMakeLists.txt
- name: Create Relase
- name: Create Tag
shell: bash
run: |
git config --global user.name 'alex1701c'
git config --global user.email 'alex1701c@users.noreply.github.com'
git commit -am "New release ${{ inputs.publish-version }}"
git tag -a "${{ inputs.publish-version }}" -m "Release version ${{ inputs.publish-version }}"
git push
git push --tags
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CMAKE_PROJECT_AUTHOR}")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")

set(KRUNNER_VERSION "${KF${QT_MAJOR_VERSION}Runner_VERSION}")
set(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_OS}-plasma${QT_MAJOR_VERSION})
# Then names of dependencies and paths might differ
if (CPACK_OS STREQUAL "ubuntu")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libkf${QT_MAJOR_VERSION}runner${QT_MAJOR_VERSION} (>=${KRUNNER_VERSION})")
set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Debian-Plasma${QT_MAJOR_VERSION}.deb")
set(CPACK_GENERATOR "DEB")
elseif(CPACK_OS STREQUAL "fedora")
set(CPACK_RPM_PACKAGE_REQUIRES "kf${QT_MAJOR_VERSION}-krunner >= ${KRUNNER_VERSION}")
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Fedora-Plasma${QT_MAJOR_VERSION}.rpm")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/lib64/qt5;/usr/lib64/qt5/plugins;/usr/lib64/qt5/plugins/kf5;/usr/lib64/qt5/plugins/kf5/krunner;/usr/share/kservices5;/usr/share/icons;/usr/share/pixmaps")
set(CPACK_GENERATOR "RPM")
elseif(CPACK_OS STREQUAL "opensuse")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libkf${QT_MAJOR_VERSION}runner${QT_MAJOR_VERSION} (>=${KRUNNER_VERSION})")
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-OpenSUSE-Plasma${QT_MAJOR_VERSION}.rpm")
set(CPACK_RPM_PACKAGE_REQUIRES "libkf${QT_MAJOR_VERSION}runner${QT_MAJOR_VERSION} (>=${KRUNNER_VERSION})")
set(CPACK_GENERATOR "RPM")
else()
unset(CPACK_PACKAGE_FILE_NAME)
endif()

# These scripts will kill krunner and when it is invoked next time the plugins will be loaded
Expand Down

0 comments on commit 8d85879

Please sign in to comment.