From 5afa8f04566dee46fc8549a63c2322b55c795bdd Mon Sep 17 00:00:00 2001 From: cnangel Date: Sun, 3 Sep 2023 11:26:06 +0800 Subject: [PATCH] add build rpm for workflow --- .github/workflows/release-workflow.yml | 170 +++++++++++++++++++++++++ .gitignore | 24 ++-- Changes-20230903.md | 5 + Conf-Libconfig.spec | 76 +++++++++++ README | 3 + 5 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release-workflow.yml create mode 100644 Changes-20230903.md create mode 100644 Conf-Libconfig.spec diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml new file mode 100644 index 0000000..163ed70 --- /dev/null +++ b/.github/workflows/release-workflow.yml @@ -0,0 +1,170 @@ +--- +name: Create Release + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + # Push events to matching v*, i.e. v1.0, v20.15.10 + - 'v*' + +jobs: + basic-build: + name: Basic Build + runs-on: ubuntu-latest + outputs: + our_date: ${{ env.our_date }} + git_hash: ${{ env.git_hash }} + cc_files_hash_id: ${{ env.cc_files_hash_id }} + version_id: ${{ env.version_id }} + package_name: ${{ env.package_name }} + deb_path: ${{ env.deb_path }} + rpm_path: ${{ env.rpm_path }} + steps: + - name: Checkout Code + uses: actions/checkout@master + - name: Set Variables + run: | + version_id=${GITHUB_REF_NAME:1} + package_name=${GITHUB_REPOSITORY##*/} + sha_short=$(git rev-parse --short "$GITHUB_SHA") + cc_hash_id=${{ hashFiles('cello.c') }} + echo "our_date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV + echo "git_hash=$sha_short" >> $GITHUB_ENV + echo "version_id=$version_id" >> $GITHUB_ENV + echo "package_name=$package_name" >> $GITHUB_ENV + echo "cc_files_hash_id=${cc_hash_id:0:10}" >> $GITHUB_ENV + echo "deb_path=debian/artifacts" >> $GITHUB_ENV + echo "rpm_path=rpmbuild/RPMS" >> $GITHUB_ENV + - name: Restore JQ and JO + id: jqjo_cache_restore + uses: actions/cache/restore@v3 + with: + path: | + ~/.local/bin/jq + ~/.local/bin/jo + key: ${{ runner.os }}-jqjo + - name: Install JQ and JO Dependencies + if: steps.jqjo_cache_restore.outputs.cache-hit != 'true' + run: | + sudo apt update + sudo apt install -y jq jo + mkdir -p ~/.local/bin + cp /usr/bin/jq ~/.local/bin + cp /usr/bin/jo ~/.local/bin + - name: Save JQ and JO + id: jqjo_cache_save + uses: actions/cache/save@v3 + with: + path: | + ~/.local/bin/jq + ~/.local/bin/jo + key: ${{ steps.jqjo_cache_restore.outputs.cache-primary-key }} + + + rpm-build-fc38: + name: Create fc38 Release + runs-on: ubuntu-latest + needs: [basic-build] + outputs: + rpm_packages: ${{ steps.output_info.outputs.rpm_packages }} + env: + our_date: ${{ needs.basic-build.outputs.our_date }} + git_hash: ${{ needs.basic-build.outputs.git_hash }} + version_id: ${{ needs.basic-build.outputs.version_id }} + package_name: ${{ needs.basic-build.outputs.package_name }} + cc_files_hash_id: ${{ needs.basic-build.outputs.cc_files_hash_id }} + deb_path: ${{ needs.basic-build.outputs.deb_path }} + rpm_path: ${{ needs.basic-build.outputs.rpm_path }} + + steps: + - name: Checkout Code + uses: actions/checkout@master + - name: Before Build Hook + run: | + sed -i 's#version: 1.0.3#version: ${{ env.version_id }}#' "${{ env.package_name }}.spec" + + - name: Restore RPM Cache + id: rpm_cache_restore + uses: actions/cache/restore@v3 + with: + path: ${{ env.rpm_path }} + key: ${{ runner.os }}-${{ env.package_name }}-${{ env.version_id }}-${{ env.cc_files_hash_id }}-${{ github.job }} + + - if: steps.rpm_cache_restore.outputs.cache-hit != 'true' + name: Build RPM Package + id: rpm_build + uses: cnangel/build-rpm-action@master + with: + docker_image: cnangel/fc38 + extra_build_deps: libconfig-devel + + - name: Save RPM Cache + id: rpm_cache_save + uses: actions/cache/save@v3 + with: + path: | + ${{ env.rpm_path }} + key: ${{ steps.rpm_cache_restore.outputs.cache-primary-key }} + + - name: Restore JQ and JO + id: jqjo_cache_restore + uses: actions/cache/restore@v3 + with: + path: | + ~/.local/bin/jq + ~/.local/bin/jo + key: ${{ runner.os }}-jqjo + + - name: Set Output Info + id: output_info + run: | + export PATH=~/.local/bin:$PATH + echo "rpm_packages=$(find ${{ env.rpm_path }} -name '*.rpm' 2>/dev/null | jo -a | jq -r 'join("'","'")')" >> $GITHUB_OUTPUT + + + publish-release: + name: Publish Release + runs-on: ubuntu-latest + needs: [rpm-build-fc38, basic-build] + env: + our_date: ${{ needs.basic-build.outputs.our_date }} + git_hash: ${{ needs.basic-build.outputs.git_hash }} + version_id: ${{ needs.basic-build.outputs.version_id }} + package_name: ${{ needs.basic-build.outputs.package_name }} + cc_files_hash_id: ${{ needs.basic-build.outputs.cc_files_hash_id }} + deb_path: ${{ needs.basic-build.outputs.deb_path }} + rpm_path: ${{ needs.basic-build.outputs.rpm_path }} + fc38_rpm_packages: ${{ needs.rpm-build-fc38.outputs.rpm_packages }} + + + steps: + - name: Checkout Code + uses: actions/checkout@master + + - name: Restore DEB Cache for Ubuntu + uses: actions/cache/restore@v3 + with: + path: | + ${{ env.deb_path }} + key: ${{ runner.os }}-${{ env.package_name }}-${{ env.version_id }}-${{ env.cc_files_hash_id }}-deb-build + - name: Restore RPM Cache for fc38 + uses: actions/cache/restore@v3 + with: + path: | + ${{ env.rpm_path }} + key: ${{ runner.os }}-${{ env.package_name }}-${{ env.version_id }}-${{ env.cc_files_hash_id }}-rpm-build-fc38 + + - name: Release ${{ github.ref_name }} + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.ref }} + name: Release ${{ github.ref_name }} + body_path: Changes-20230903.md + files: | + README + ${{ env.fc38_rpm_packages }} + token: ${{ secrets.SSE_TOKEN }} + draft: false + prerelease: false + diff --git a/.gitignore b/.gitignore index 3baa7da..5e2251b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,20 @@ +*.bak blib* -find . -name "*.bak" -print -find . -name .svn -print -Makefile -Makefile.old -Build _build* -pm_to_blib* -*.tar.gz -.lwpcookies +Build +*.c Conf-Libconfig-* cover_db -*.c -*.o -#*.bs -*.bak Libconfig.bs Libconfig.c Libconfig.o +.lwpcookies +Makefile +Makefile.old +MYMETA.json +MYMETA.yml +*.o +pm_to_blib* stdio2.h.gcov string3.h.gcov - +*.tar.gz diff --git a/Changes-20230903.md b/Changes-20230903.md new file mode 100644 index 0000000..a69721e --- /dev/null +++ b/Changes-20230903.md @@ -0,0 +1,5 @@ +Changes in this Release v1.0.3 +- Add workflow for github. +- Fix some issues. +- Update general value. + diff --git a/Conf-Libconfig.spec b/Conf-Libconfig.spec new file mode 100644 index 0000000..eb3489a --- /dev/null +++ b/Conf-Libconfig.spec @@ -0,0 +1,76 @@ +# +# - Conf-Libconfig - +# This spec file was automatically generated by cpan2rpm [ver: 2.029] +# The following arguments were used: +# Conf-Libconfig-0.08.tar.gz +# For more information on cpan2rpm please visit: http://perl.arix.com/ +# +%define _tmppath %{_topdir}/BUILDROOT +%define pkgname Conf-Libconfig +%define filelist %{pkgname}-%{version}-filelist +%define NVR %{pkgname}-%{version}-%{release} +%define maketest 1 + +name: perl-Conf-Libconfig +summary: Conf-Libconfig - Perl extension for libconfig +version: 1.0.3 +release: 1%{?dist} +vendor: Cnangel +packager: Cnangel +license: Artistic +group: Applications/CPAN +url: https://github.com/cnangel/Conf-Libconfig +buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) +buildarch: x86_64 +prefix: %{_prefix} +source: %{name}-%{version}.tar.gz +BuildRequires: perl-bignum gcc perl-CPAN +BuildRequires: perl(Test::Deep) perl(Test::Warn) perl(Test::Exception) perl(ExtUtils::PkgConfig) + +%description +You can use `Conf::Libconfig' for perl config, and support Scalar, Array and Hash data structures etc. +like C or C++ function. `Conf::Libconfig' could reduce your config file and quote by C/C++ transportability. + +# +# This package was generated automatically with the cpan2rpm +# utility. To get this software or for more information +# please visit: http://perl.arix.com/ +# + +%prep +%setup -q + +%build +perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 +%{make_build} + +%check +%if %maketest +%{__make} test +%endif + +%install +rm -rf %{buildroot} +%{make_install} + + +%clean +[ "%{buildroot}" != "/" ] && rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%doc Changes README +%{perl_archlib}/* +%{_mandir}/man3/* + +%changelog +* Sun Sep 03 2023 Cnangel 1.0.3-1 +- Fix some issues. +* Sun Mar 19 2023 Cnangel 1.0.0-1 +- Upgrade version 1.0.0 +* Sun Mar 19 2023 Cnangel 0.200-1 +- Update general value. +* Sun May 29 2022 Cnangel 0.101-1 +- Update for libconfig-1.7.3 +* Mon Aug 5 2013 cnangel@localhost.localdomain +- Initial build. diff --git a/README b/README index 9a3aae9..0f07088 100644 --- a/README +++ b/README @@ -1,3 +1,6 @@ +[![Releasing](https://github.com/cnangel/Conf-Libconfig/actions/workflows/lint.yml/badge.svg)](https://github.com/cnangel/Conf-Libconfig/actions/workflows/release-workflow.yml) +[![Testing](https://github.com/cnangel/Conf-Libconfig/actions/workflows/test.yml/badge.svg)](https://github.com/cnangel/Conf-Libconfig/actions/workflows/test.yml) + Conf-Libconfig Perl bindings to the C library libconfig