From 7aea9484e45842cd2a1c47d0be9e9a568294ea07 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 28 Mar 2023 16:33:52 +0200 Subject: [PATCH] Build and release using AlmaLinux 8 and 9. (#45) - Build and release using AlmaLinux 8 and 9. - Align Makefile with other repositories. - Allow long yaml files for GitHub Actions --- .github/linters/.yaml-lint.yml | 6 +++ .github/workflows/build.yml | 48 ++++++++++++----------- .github/workflows/lint.yml | 5 +-- .github/workflows/release.yml | 70 ++++++++++++++++++---------------- Makefile | 9 ++--- 5 files changed, 76 insertions(+), 62 deletions(-) create mode 100644 .github/linters/.yaml-lint.yml diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 0000000..84224f1 --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,6 @@ +--- +extends: "default" + +rules: + line-length: + max: 180 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c64eee2..44fcd21 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: pull_request: jobs: - centos7: + build-centos7: name: Build CentOS 7 RPMs runs-on: ubuntu-latest container: quay.io/centos/centos:7 @@ -25,12 +25,12 @@ jobs: with: name: rpms7 path: | - build/RPMS/noarch/bdii-*-1.el7.noarch.rpm + build/RPMS/noarch/bdii-*.el7.noarch.rpm - centos8: - name: Build CentOS Stream 8 RPMs + build-almalinux8: + name: Build AlmaLinux 8 RPMs runs-on: ubuntu-latest - container: quay.io/centos/centos:stream8 + container: almalinux:8 steps: - uses: actions/checkout@v3 with: @@ -47,12 +47,12 @@ jobs: with: name: rpms8 path: | - build/RPMS/noarch/bdii-*-1.el8.noarch.rpm + build/RPMS/noarch/bdii-*.el8.noarch.rpm - centos9: - name: Build CentOS Stream 9 RPMs + build-almalinux9: + name: Build AlmaLinux 9 RPMs runs-on: ubuntu-latest - container: quay.io/centos/centos:stream9 + container: almalinux:9 steps: - uses: actions/checkout@v3 with: @@ -69,12 +69,12 @@ jobs: with: name: rpms9 path: | - build/RPMS/noarch/bdii-*-1.el9.noarch.rpm + build/RPMS/noarch/bdii-*.el9.noarch.rpm # XXX Dependency from EPEL: glue-schema - centos7-install: + install-centos7: name: Install CentOS 7 RPMs - needs: centos7 + needs: build-centos7 runs-on: ubuntu-latest container: quay.io/centos/centos:7 steps: @@ -87,12 +87,16 @@ jobs: yum localinstall -y bdii-*.el7.noarch.rpm # XXX Dependency from EPEL: glue-schema - # Dependency from PowerTools: openldap-servers - centos8-install: - name: Install CentOS Stream 8 RPMs - needs: centos8 + # FIXME: openldap-servers is in CentOS 8 Stream Powertools, but not in AlmaLinux PowerTools + # See https://bugs.almalinux.org/view.php?id=222 + # Currently instaling using the package from devel repository + # See https://bugs.almalinux.org/view.php?id=100 + # https://repo.almalinux.org/almalinux/8/devel/x86_64/os/Packages/ + install-almalinux8: + name: Install AlmaLinux 8 RPMs + needs: build-almalinux8 runs-on: ubuntu-latest - container: quay.io/centos/centos:stream8 + container: almalinux:8 steps: - uses: actions/download-artifact@v3 with: @@ -100,15 +104,15 @@ jobs: - name: Install generated RPMs run: | yum install -y epel-release - sed -i 's/^enabled=0/enabled=1/' /etc/yum.repos.d/CentOS-Stream-PowerTools.repo + yum install -y https://repo.almalinux.org/almalinux/8/devel/x86_64/os/Packages/openldap-servers-2.4.46-18.el8.x86_64.rpm yum localinstall -y bdii-*.el8.noarch.rpm # XXX Dependencies from EPEL: glue-schema, openldap-servers - centos9-install: - name: Install CentOS Stream 9 RPMs - needs: centos9 + install-almalinux9: + name: Install AlmaLinux 9 RPMs + needs: build-almalinux9 runs-on: ubuntu-latest - container: quay.io/centos/centos:stream9 + container: almalinux:9 steps: - uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cdc3cd9..0d5f6b8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,7 +6,7 @@ on: jobs: super-lint: - name: Lint with Supper-Linter + name: Lint with Super-Linter runs-on: ubuntu-latest steps: @@ -31,5 +31,4 @@ jobs: # Fail on errors DISABLE_ERRORS: false # shellcheck conf - SHELLCHECK_OPTS: - -e SC1090,SC2046,SC2164,SC2166,SC1091,SC2086,SC2001,SC2219,SC2181 + SHELLCHECK_OPTS: -e SC1090,SC2046,SC2164,SC2166,SC1091,SC2086,SC2001,SC2219,SC2181 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a57f55..208e775 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ on: - "v*" jobs: - centos7: + build-centos7: name: Build centOS 7 RPMs runs-on: ubuntu-latest container: quay.io/centos/centos:7 @@ -29,13 +29,13 @@ jobs: with: name: rpms7 path: | - build/RPMS/noarch/bdii-*-1.el7.noarch.rpm - build/SRPMS/bdii-*-1.el7.src.rpm + build/RPMS/noarch/bdii-*.el7.noarch.rpm + build/SRPMS/bdii-*.el7.src.rpm - centos8: - name: Build CentOS Stream 8 RPMs + build-almalinux8: + name: Build AlmaLinux 8 RPMs runs-on: ubuntu-latest - container: quay.io/centos/centos:stream8 + container: almalinux:8 steps: - uses: actions/checkout@v3 with: @@ -51,13 +51,13 @@ jobs: with: name: rpms8 path: | - build/RPMS/noarch/bdii-*-1.el8.noarch.rpm - build/SRPMS/bdii-*-1.el8.src.rpm + build/RPMS/noarch/bdii-*.el8.noarch.rpm + build/SRPMS/bdii-*.el8.src.rpm - centos9: - name: Build CentOS Stream 9 RPMs + build-almalinux9: + name: Build AlmaLinux 9 RPMs runs-on: ubuntu-latest - container: quay.io/centos/centos:stream9 + container: almalinux:9 steps: - uses: actions/checkout@v3 with: @@ -73,12 +73,14 @@ jobs: with: name: rpms9 path: | - build/RPMS/noarch/bdii-*-1.el9.noarch.rpm - build/SRPMS/bdii-*-1.el9.src.rpm + build/RPMS/noarch/bdii-*.el9.noarch.rpm + build/SRPMS/bdii-*.el9.src.rpm release7: name: Upload CentOS 7 release artefacts - needs: centos7 + permissions: + contents: write # to upload release asset (softprops/action-gh-release) + needs: build-centos7 runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 @@ -87,8 +89,8 @@ jobs: - name: Find package name id: package_name_centos7 run: | - rpm_path=$(find . -name 'bdii-*-1.el7.noarch.rpm') - src_path=$(find . -name 'bdii-*-1.el7.src.rpm') + rpm_path=$(find . -name 'bdii-*.el7.noarch.rpm') + src_path=$(find . -name 'bdii-*.el7.src.rpm') echo "rpm_path=${rpm_path}" >> "$GITHUB_OUTPUT" echo "src_path=${src_path}" >> "$GITHUB_OUTPUT" - name: Attach CentOS 7 RPMs to the release @@ -102,51 +104,55 @@ jobs: ${{ steps.package_name_centos7.outputs.src_path }} release8: - name: Upload CentOS Stream 8 release artefacts - needs: centos8 + name: Upload AlmaLinux 8 release artefacts + permissions: + contents: write # to upload release asset (softprops/action-gh-release) + needs: build-almalinux8 runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 with: name: rpms8 - name: Find package name - id: package_name_centos8 + id: package_name_almalinux8 run: | - rpm_path=$(find . -name 'bdii-*-1.el8.noarch.rpm') - src_path=$(find . -name 'bdii-*-1.el8.src.rpm') + rpm_path=$(find . -name 'bdii-*.el8.noarch.rpm') + src_path=$(find . -name 'bdii-*.el8.src.rpm') echo "rpm_path=${rpm_path}" >> "$GITHUB_OUTPUT" echo "src_path=${src_path}" >> "$GITHUB_OUTPUT" - - name: Attach CentOS Stream 8 RPMs to the release + - name: Attach AlmaLinux 8 RPMs to the release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: fail_on_unmatched_files: true files: | - ${{ steps.package_name_centos8.outputs.rpm_path }} - ${{ steps.package_name_centos8.outputs.src_path }} + ${{ steps.package_name_almalinux8.outputs.rpm_path }} + ${{ steps.package_name_almalinux8.outputs.src_path }} release9: - name: Upload CentOS Stream 9 release artefacts - needs: centos9 + name: Upload AlmaLinux 9 release artefacts + permissions: + contents: write # to upload release asset (softprops/action-gh-release) + needs: build-almalinux9 runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 with: name: rpms9 - name: Find package name - id: package_name_centos9 + id: package_name_almalinux9 run: | - rpm_path=$(find . -name 'bdii-*-1.el9.noarch.rpm') - src_path=$(find . -name 'bdii-*-1.el9.src.rpm') + rpm_path=$(find . -name 'bdii-*.el9.noarch.rpm') + src_path=$(find . -name 'bdii-*.el9.src.rpm') echo "rpm_path=${rpm_path}" >> "$GITHUB_OUTPUT" echo "src_path=${src_path}" >> "$GITHUB_OUTPUT" - - name: Attach CentOS Stream 9 RPMs to the release + - name: Attach AlmaLinux 9 RPMs to the release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: fail_on_unmatched_files: true files: | - ${{ steps.package_name_centos9.outputs.rpm_path }} - ${{ steps.package_name_centos9.outputs.src_path }} + ${{ steps.package_name_almalinux9.outputs.rpm_path }} + ${{ steps.package_name_almalinux9.outputs.src_path }} diff --git a/Makefile b/Makefile index b0ddcdf..8acef94 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,7 @@ NAME=$(shell grep Name: *.spec | sed 's/^[^:]*:[^a-zA-Z]*//') VERSION=$(shell grep Version: *.spec | sed 's/^[^:]*:[^0-9]*//') RELEASE=$(shell grep Release: *.spec | cut -d"%" -f1 | sed 's/^[^:]*:[^0-9]*//') build=$(shell pwd)/build -DATE=$(shell date "+%a, %d %b %Y %T %z") -dist=$(shell rpm --eval '%dist' | sed 's/%dist/.el5/') +dist=$(shell rpm --eval '%dist') init_dir=$(shell rpm --eval '%{_initrddir}' || echo '/etc/init.d/') default: @@ -42,7 +41,7 @@ install: @install -m 0644 LICENSE.txt $(prefix)/usr/share/doc/bdii/ dist: - @mkdir -p $(build)/$(NAME)-$(VERSION)/ + @mkdir -p $(build)/$(NAME)-$(VERSION)/ rsync -HaS --exclude ".git" --exclude "$(build)" * $(build)/$(NAME)-$(VERSION)/ cd $(build); tar --gzip -cf $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)/; cd - @@ -59,10 +58,10 @@ prepare: dist cp $(NAME).spec $(build)/SPECS srpm: prepare - rpmbuild -bs --define="dist ${dist}" --define='_topdir ${build}' $(build)/SPECS/$(NAME).spec + rpmbuild -bs --define="dist $(dist)" --define="_topdir $(build)" $(build)/SPECS/$(NAME).spec rpm: srpm - rpmbuild --rebuild --define='_topdir ${build}' --define="dist ${dist}" $(build)/SRPMS/$(NAME)-$(VERSION)-$(RELEASE)$(dist).src.rpm + rpmbuild --rebuild --define="dist $(dist)" --define="_topdir $(build)" $(build)/SRPMS/$(NAME)-$(VERSION)-$(RELEASE)$(dist).src.rpm clean: rm -f *~ $(NAME)-$(VERSION).tar.gz