forked from ZoneMinder/zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 9
243 lines (208 loc) · 8.09 KB
/
build-rpm-packages.yml
File metadata and controls
243 lines (208 loc) · 8.09 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: build-rpm-packages-signed
on:
push:
branches: [ master ]
permissions:
contents: write
env:
GPG_KEY_ID: ${{ secrets.ZMREPO_GPG_KEY_ID }}
GPG_PASSPHRASE: ${{ secrets.ZMREPO_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_B64: ${{ secrets.ZMREPO_GPG_PRIVATE_KEY_B64 }}
TZ: America/New_York
jobs:
build-rpm:
name: Build & sign RPM (${{ matrix.distro }})
if: github.repository == 'ZoneMinder/zoneminder'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- distro: "rockylinux:9"
releasever: "9"
family: "el"
- distro: "rockylinux:8"
releasever: "8"
family: "el"
- distro: "fedora:43"
releasever: "43"
family: "fedora"
- distro: "fedora:42"
releasever: "42"
family: "fedora"
- distro: "fedora:41"
releasever: "41"
family: "fedora"
container:
image: ${{ matrix.distro }}
steps:
- name: Enable EPEL and RPMFusion (EL)
if: matrix.family == 'el'
run: |
set -eux
dnf -y install dnf-plugins-core epel-release
dnf -y install "https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-${{ matrix.releasever }}.noarch.rpm"
if [ "${{ matrix.releasever }}" == "8" ]; then
dnf config-manager --set-enabled powertools
else
dnf config-manager --set-enabled crb
fi
- name: Enable RPMFusion (Fedora)
if: matrix.family == 'fedora'
run: |
set -eux
dnf -y install dnf-plugins-core
dnf -y install "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${{ matrix.releasever }}.noarch.rpm"
- name: Install build tools
run: |
set -eux
# Install systemd to resolve conflicts with systemd-standalone-tmpfiles
# in container images (needed by net-tools, mosquitto, etc.)
dnf -y install --allowerasing systemd
dnf -y install \
arp-scan \
git \
rpm-build \
rpmdevtools \
rpmlint \
gnupg2 \
iproute \
wget \
rsync \
openssh-clients \
ca-certificates \
createrepo_c
- name: Setup RPM build directory
run: |
set -eux
rm -rf ~/rpmbuild
rpmdev-setuptree
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.ZMREPO_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.ZMREPO_GPG_PASSPHRASE }}
git_user_signingkey: false
git_commit_gpgsign: false
- name: Configure RPM signing
run: |
set -eux
cat > ~/.rpmmacros << EOF
%_signature gpg
%_gpg_name ${GPG_KEY_ID}
%__gpg /usr/bin/gpg2
%__gpg_sign_cmd %{__gpg} gpg --batch --verbose --no-armor --no-secmem-warning -u "%{_gpg_name}" -sbo %{__signature_filename} --digest-algo sha256 %{__plaintext_filename}'
EOF
- name: Install build dependencies
run: |
set -eux
dnf -y builddep distros/redhat/zoneminder.spec
- name: Determine version and prepare sources
id: version
run: |
set -eux
VERSION=$(cat version.txt)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
git config --global --add safe.directory /__w/zoneminder/zoneminder
# Calculate snapshot version
versionhash=$(git log -n1 --pretty=format:%h version.txt)
numcommits=$(git rev-list ${versionhash}..HEAD --count)
SNAPSHOT="$(date +%Y%m%d).${numcommits}"
echo "snapshot=${SNAPSHOT}" >> $GITHUB_OUTPUT
# Update version in spec file
sed -i "s/^Version:.*/Version: ${VERSION}/" distros/redhat/zoneminder.spec
sed -i "s/^Release:.*/Release: 0.${SNAPSHOT}%{?dist}/" distros/redhat/zoneminder.spec
# Copy spec file to SPECS
cp distros/redhat/zoneminder.spec ~/rpmbuild/SPECS/
- name: Download submodule sources
run: |
set -eux
VERSION=${{ steps.version.outputs.version }}
# Read submodule versions from spec file
CRUD_VERSION=$(grep '%global crud_version' distros/redhat/zoneminder.spec | awk '{print $3}')
CEB_VERSION=$(grep '%global ceb_version' distros/redhat/zoneminder.spec | awk '{print $3}')
RTSP_COMMIT=$(grep '%global rtspserver_commit' distros/redhat/zoneminder.spec | awk '{print $3}')
CXXURL_VERSION=$(grep '%global CxxUrl_version' distros/redhat/zoneminder.spec | awk '{print $3}')
# Download main ZoneMinder source tarball
git archive --format=tar.gz --prefix=zoneminder-${VERSION}/ HEAD > ~/rpmbuild/SOURCES/zoneminder-${VERSION}.tar.gz
# Download Crud
curl -L -o ~/rpmbuild/SOURCES/crud-${CRUD_VERSION}.tar.gz \
"https://github.com/FriendsOfCake/crud/archive/v${CRUD_VERSION}.tar.gz"
# Download CakePHP-Enum-Behavior
curl -L -o ~/rpmbuild/SOURCES/cakephp-enum-behavior-${CEB_VERSION}.tar.gz \
"https://github.com/ZoneMinder/CakePHP-Enum-Behavior/archive/${CEB_VERSION}.tar.gz"
# Download RtspServer
curl -L -o ~/rpmbuild/SOURCES/RtspServer-${RTSP_COMMIT}.tar.gz \
"https://github.com/ZoneMinder/RtspServer/archive/${RTSP_COMMIT}.tar.gz"
# Download CxxUrl
curl -L -o ~/rpmbuild/SOURCES/CxxUrl-${CXXURL_VERSION}.tar.gz \
"https://github.com/chmike/CxxUrl/archive/${CXXURL_VERSION}.tar.gz"
# List sources
ls -la ~/rpmbuild/SOURCES/
- name: Build SRPM
run: |
set -eux
rpmbuild -bs ~/rpmbuild/SPECS/zoneminder.spec
ls -la ~/rpmbuild/SRPMS/
- name: Build RPMs
env:
SMPFLAGS: "-j$(nproc)"
run: |
set -eux
rpmbuild --rebuild ~/rpmbuild/SRPMS/zoneminder-*.src.rpm
ls -la ~/rpmbuild/RPMS/
- name: Sign RPMs
run: |
set -eux
# Sign all RPM packages
echo "${GPG_PASSPHRASE}" | gpg2 --batch --yes --passphrase-fd 0 \
--pinentry-mode loopback -ab ~/rpmbuild/SRPMS/*.src.rpm || true
for rpm in ~/rpmbuild/RPMS/*/*.rpm; do
echo "${GPG_PASSPHRASE}" | rpm --addsign "$rpm" || echo "Warning: Failed to sign $rpm"
done
# Verify signatures
rpm -K ~/rpmbuild/RPMS/*/*.rpm || true
- name: Collect RPM artifacts
run: |
set -eux
mkdir -p artifacts/rpm
cp ~/rpmbuild/SRPMS/*.src.rpm artifacts/rpm/ || true
cp ~/rpmbuild/RPMS/*/*.rpm artifacts/rpm/ || true
ls -la artifacts/rpm/
- name: Sanitize artifact name
id: prep_artifact_name
run: |
sanitized_distro_name=$(echo -n "${{ matrix.distro }}" | sed -e 's/[;\\\/:<>"|*?]/_/g' -e 's/__*/_/g')
echo "artifact_name=rpm-${sanitized_distro_name}" >> $GITHUB_ENV
- name: Upload RPM artifacts
uses: actions/upload-artifact@v6
with:
path: artifacts/rpm
name: ${{ env.artifact_name }}
- name: Publish to ZMREPO
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.ZMREPO_SSH_KEY }}
ARGS: "-rltgoDzvO"
SOURCE: artifacts/rpm/
REMOTE_HOST: ${{ secrets.ZMREPO_HOST }}
REMOTE_USER: ${{ secrets.ZMREPO_SSH_USER }}
TARGET: rpm/master/${{ matrix.family }}/${{ matrix.releasever }}/x86_64/
release:
name: Create GitHub Release (on tag)
needs: build-rpm
if: github.repository == 'ZoneMinder/zoneminder' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v7
with:
path: dist
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: dist/**/*