From f771646c0bd8e218d793314f058fb7505644c8f3 Mon Sep 17 00:00:00 2001 From: Luca Bassi Date: Thu, 5 Dec 2024 16:24:40 +0100 Subject: [PATCH] Add CI workflow to build RPMs --- .github/workflows/build-rpm.yaml | 85 ++++++++++++++++ storm-webdav.spec | 162 +++++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 .github/workflows/build-rpm.yaml create mode 100644 storm-webdav.spec diff --git a/.github/workflows/build-rpm.yaml b/.github/workflows/build-rpm.yaml new file mode 100644 index 00000000..a44dcf84 --- /dev/null +++ b/.github/workflows/build-rpm.yaml @@ -0,0 +1,85 @@ +name: Build RPM +on: push +jobs: + build-rpm: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + strategy: + fail-fast: false + matrix: + os: [almalinux] + version: [8, 9] + runs-on: ubuntu-latest + container: '${{ matrix.os }}:${{ matrix.version }}' + steps: + - name: Install dependencies + run: | + dnf upgrade -y + [[ "${{ matrix.version }}" = 8 ]] && dnf module enable -y maven:3.8/common + dnf install -y git rpmdevtools rpmlint maven-openjdk11 + - name: Setup build tree + run: | + mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + - name: Check out repository code + uses: actions/checkout@v4 + with: + path: 'rpmbuild/BUILD' + fetch-depth: 0 + - name: Create .rpm + run: | + cp rpmbuild/BUILD/storm-webdav.spec rpmbuild/SPECS/storm-webdav.spec + rpmlint rpmbuild/SPECS/storm-webdav.spec + rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/storm-webdav.spec + - uses: actions/upload-artifact@v4 + with: + name: build-rpm-${{ matrix.os }}-${{ matrix.version }} + path: | + rpmbuild/RPMS/noarch/*.rpm + publish-nightly: + needs: build-rpm + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/develop' + env: + NEXUS_USER: ${{ secrets.NEXUS_STORM_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_STORM_PASSWORD }} + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: Create release + run: | + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-8/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-nightly/redhat8/ + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-9/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-nightly/redhat9/ + publish-beta: + needs: build-rpm + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + env: + NEXUS_USER: ${{ secrets.NEXUS_STORM_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_STORM_PASSWORD }} + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: Create release + run: | + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-8/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-beta/redhat8/ + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-9/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-beta/redhat9/ + publish-stable: + needs: build-rpm + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + env: + NEXUS_USER: ${{ secrets.NEXUS_STORM_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_STORM_PASSWORD }} + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: Create release + run: | + GITHUB_REF=${{ github.ref }} + TAG_NAME=${GITHUB_REF#refs/tags/} + if [[ ${TAG_NAME} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-8/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-stable/redhat8/ + curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file build-rpm-almalinux-9/*.rpm https://repo.cloud.cnaf.infn.it/repository/storm-rpm-stable/redhat9/ + fi diff --git a/storm-webdav.spec b/storm-webdav.spec new file mode 100644 index 00000000..04680781 --- /dev/null +++ b/storm-webdav.spec @@ -0,0 +1,162 @@ +# Copyright (c) Istituto Nazionale di Fisica Nucleare, 2014-2023. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +## Turn off meaningless jar repackaging +%define __jar_repack 0 + +%global base_version 1.5.0 +%global release_version 0 +%global slash_name storm/webdav + +Name: storm-webdav +Version: %{base_version} +Release: %{release_version}%{?dist} +Summary: The StoRM WebDAV server +Group: Applications/File +License: Apache-2.0 +URL: https://github.com/italiangrid/storm-webdav + +BuildArch: noarch + +BuildRequires: maven-openjdk11 + +Requires: java-11-openjdk-headless + +%description +StoRM provides an SRM interface to any POSIX filesystem with direct file +access ("file:" transport protocol), but can take advantage of special +features of high performance parallel and cluster file systems, as GPFS from +IBM and Lustre from SUN. + +This package provides the StoRM WebDAV server. + +%prep + +%build +mvn -s maven/cnaf-mirror-settings.xml -DskipTests -U clean package + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot} +tar -C %{buildroot} -xvzf target/%{name}-server.tar.gz + +%files + +%attr(644,root,root) %{_exec_prefix}/lib/systemd/system/%{name}.service +%dir %attr(644,root,root) %{_sysconfdir}/systemd/system/%{name}.service.d +%attr(644,root,root) %config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/filelimit.conf +%attr(644,root,root) %config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/storm-webdav.conf + +%attr(755,root,root) %dir %{_javadir}/%{name} +%attr(644,root,root) %{_javadir}/%{name}/%{name}-server.jar + +%defattr(640,root,storm,755) + +%config(noreplace) %{_sysconfdir}/%{slash_name}/logback.xml +%config(noreplace) %{_sysconfdir}/%{slash_name}/logback-access.xml +%config(noreplace) %{_sysconfdir}/%{slash_name}/config/application.yml + +%{_sysconfdir}/%{slash_name}/README.md + +%dir %{_sysconfdir}/%{slash_name}/sa.d +%{_sysconfdir}/%{slash_name}/sa.d/README.md +%{_sysconfdir}/%{slash_name}/sa.d/*.template + +%dir %{_sysconfdir}/%{slash_name}/config +%{_sysconfdir}/%{slash_name}/config/README.md + +%dir %{_sysconfdir}/%{slash_name}/vo-mapfiles.d +%{_sysconfdir}/%{slash_name}/vo-mapfiles.d/README.md + +%attr(750,storm,storm) %dir %{_localstatedir}/log/storm +%attr(750,storm,storm) %dir %{_localstatedir}/log/storm/webdav +%attr(755,storm,storm) %dir %{_localstatedir}/lib/%{name}/work + +%pre +# create user storm, if it does not exist +getent group storm > /dev/null || groupadd -r storm +getent passwd storm > /dev/null || useradd -r -g storm \ + -d %{_sysconfdir}/storm -s /sbin/nologin -c "StoRM server account" storm + +%post +# when installing +if [ "$1" = "1" ] ; then + # enable the service + systemctl enable %{name}.service +# when upgrading +elif [ $1 -gt 1 ] ; then + # restart the service + systemctl daemon-reload + systemctl restart %{name}.service +fi + +%preun +# when uninstalling +if [ "$1" = "0" ] ; then + # stop and disable service + systemctl stop %{name}.service +fi + +%changelog +* Thu Dec 5 2024 Enrico Vianello - 1.5.0-0 +- Packaging for version 1.5.0-0 + +* Wed Jun 26 2024 Enrico Vianello - 1.4.3-0 +- Packaging for version 1.4.3-0 + +* Mon Jun 26 2023 Enrico Vianello - 1.4.2-1 +- Packaging for version 1.4.2-1 + +* Fri Oct 1 2021 Enrico Vianello - 1.4.2-0 +- Packaging for version 1.4.2-0 + +* Tue May 11 2021 Enrico Vianello - 1.4.1-1 +- Packaging for version 1.4.1-1 + +* Wed Apr 28 2021 Enrico Vianello - 1.4.1-0 +- Packaging for version 1.4.1-0 + +* Thu Apr 1 2021 Enrico Vianello - 1.4.0-1 +- Packaging for version 1.4.0-1 + +* Mon Feb 1 2021 Enrico Vianello - 1.4.0-0 +- Removed stuff related to centos6: init script and sysconfig file, service commands and others +- Added right permissions and ownership to log parent directory + +* Fri Dec 11 2020 Andrea Ceccanti - 1.4.0-0 +- Packaging for version 1.4.0-0 + +* Mon Sep 14 2020 Andrea Ceccanti - 1.3.1-1 +- Packaging for version 1.3.1-1 + +* Fri Aug 07 2020 Enrico Vianello - 1.3.0-1 +- Packaging for version to 1.3.0-1 + +* Fri Mar 27 2020 Enrico Vianello - 1.3.0-0 +- Packaging for version 1.3.0-0 + +* Fri Dec 13 2019 Enrico Vianello - 1.2.1-1 +- Packaging for version 1.2.1 + +* Wed Nov 13 2019 Enrico Vianello - 1.2.0-0 +- Fixed preun and post phases by addind el7 specific commands + +* Tue Jun 11 2019 Enrico Vianello - 1.2.0-0 +- Packaging for version 1.2.0 + +* Fri Oct 12 2018 Andrea Ceccanti - 1.1.0-0 +- Packaging for version 1.1.0 + +* Mon Sep 1 2014 Andrea Ceccanti - 1.0.0-0 +- Initial packaging