-
Notifications
You must be signed in to change notification settings - Fork 5
154 lines (141 loc) · 5.14 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build KRunner Plugins
on:
push:
branches:
- master
- github_actions
pull_request:
branches:
- master
workflow_dispatch:
inputs:
publish-version:
description: "new version that should get published"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- name: ubuntu
image: invent-registry.kde.org/neon/docker-images/plasma:user
- name: ubuntu
image: ubuntu:24.04
- name: opensuse
image: opensuse/tumbleweed
- name: fedora
image: fedora
plasma_version: [plasma5, plasma6]
exclude:
- os:
image: invent-registry.kde.org/neon/docker-images/plasma:user
plasma_version: plasma5
- os:
image: ubuntu:24.04
plasma_version: plasma6
runs-on: ubuntu-latest
name: ${{ matrix.os.name }}-${{ matrix.plasma_version }}
container:
image: ${{ matrix.os.image }}
options: --user root
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
README.md
- name: Install dependencies
shell: bash
run: |
echo "Dependencies for install-${{ matrix.os.name }}-${{ matrix.plasma_version }}"
CMD=$(sed -n '/```bash install-${{ matrix.os.name }}-${{ matrix.plasma_version }}/,/```/p' README.md | head -n -1 | tail -n +2 |sed 's/sudo //')
if [[ "${{ matrix.os.name }}" == "ubuntu" ]]; then
apt update
export DEBIAN_FRONTEND=noninteractive
echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf
elif [[ "${{ matrix.os.name }}" == "fedora" ]]; then
echo "defaultyes=True" >> /etc/dnf/dnf.conf
dnf install rpm-build
elif [[ "${{ matrix.os.name }}" == "opensuse" ]]; then
zypper refresh
CMD=$(echo $CMD | sed 's/zypper/zypper --non-interactive/')
zypper install -y rpm-build
else
echo "Unsupported OS: ${{ matrix.os.name }}"
exit 1
fi
echo "$CMD"
eval $CMD
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Update Version in CMakeLists
run: |
publish_version="${{ inputs.publish-version }}"
cmake_version=$(grep -Po '(?<=set\s*\(\s*CMAKE_PROJECT_VERSION\s*")[0-9]+\.[0-9]+\.[0-9]+' 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."
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
- name: Create build directory
run: mkdir -p build
- name: Build and install
id: build
working-directory: build/
shell: bash
run: |
CMAKE_ARGS=".. -DCMAKE_BUILD_TYPE=RelWithDebInfo"
if [[ -n "${{ inputs.publish-version }}" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DCPACK_OS=${{ matrix.os.name }}"
fi
if [[ "${{ matrix.plasma_version }}" == "plasma6" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DBUILD_WITH_QT6=ON"
else
CMAKE_ARGS="$CMAKE_ARGS -DBUILD_WITH_QT6=OFF"
fi
echo cmake $CMAKE_ARGS
cmake $CMAKE_ARGS
cmake --build . -j2
cmake --install .
- name: Run tests
working-directory: build/
run: ctest -V
- name: CPack
if: inputs.publish-version
working-directory: build
id: cpack
shell: bash
run: |
cpack | tee cpack.out
filepath=$(sed -nr 's/.*package: (.+) generated\./\1/p' cpack.out)
echo "filepath=$filepath" >> "$GITHUB_OUTPUT"
echo "filename=$(basename $filepath)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
if: inputs.publish-version
with:
name: ${{ steps.cpack.outputs.filename }}
path: ${{ steps.cpack.outputs.filepath }}
release:
runs-on: ubuntu
needs: build
steps:
- 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
shell: bash
if: false
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