diff --git a/.github/actions/buildrpm/Dockerfile b/.github/actions/buildrpm/Dockerfile new file mode 100644 index 00000000..04790e67 --- /dev/null +++ b/.github/actions/buildrpm/Dockerfile @@ -0,0 +1,23 @@ +FROM opensuse/tumbleweed:latest + +# Update +RUN zypper patch -y + +# Install necessary packages +RUN zypper in -y \ + rpm-build rpmdevtools dnf-plugins-core python3 git gcc fdupes \ + python311-pip python311-setuptools python311-setuptools_scm python311-wheel \ + python312-pip python312-setuptools python312-setuptools_scm python312-wheel \ + python313-pip python313-setuptools python313-setuptools_scm python313-wheel + +WORKDIR /usr/src/packages + +# Copy necessary files to build a rpm package +COPY python-bytecode.spec SPECS/ +COPY python-bytecode.tar.gz SOURCES/ + +# Set up the entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/buildrpm/action.yml b/.github/actions/buildrpm/action.yml new file mode 100644 index 00000000..d3d5b2d1 --- /dev/null +++ b/.github/actions/buildrpm/action.yml @@ -0,0 +1,10 @@ +name: "Build RPM" +description: "Build RPM package" + +outputs: + rpm-package: + description: "Bytecode is a Python module to generate and modify bytecode" + +runs: + using: "docker" + image: "Dockerfile" diff --git a/.github/actions/buildrpm/entrypoint.sh b/.github/actions/buildrpm/entrypoint.sh new file mode 100644 index 00000000..3bddc475 --- /dev/null +++ b/.github/actions/buildrpm/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd /usr/src/packages + +# Update release verion on spec file +sed -i -e "s/##RPMVERSION##/$RELEASE_VERSION/" SPECS/python-bytecode.spec + +rpmbuild -bb SPECS/python-bytecode.spec +mv RPMS/noarch/*.rpm $GITHUB_WORKSPACE diff --git a/.github/actions/buildrpm/python-bytecode.spec b/.github/actions/buildrpm/python-bytecode.spec new file mode 100644 index 00000000..2db69552 --- /dev/null +++ b/.github/actions/buildrpm/python-bytecode.spec @@ -0,0 +1,55 @@ +# +# spec file for package python-bytecode +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: python-bytecode +Version: ##RPMVERSION## +Release: 1%{?dist} +Summary: Python module to generate and modify bytecode +License: MIT +URL: https://github.com/mrcaique/bytecode +Source: /github/home/rpmbuild/SOURCES/%{name}.tar.gz +BuildRequires: python-rpm-macros +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools >= 61.2} +BuildRequires: %{python_module setuptools_scm >= 3.4.3} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildArch: noarch +%python_subpackages + +%description +Python module to generate and modify bytecode + +%prep +%autosetup -p1 -n bytecode + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%files %{python_files} +%doc README.rst +%license COPYING +%{python_sitelib}/bytecode +%{python_sitelib}/bytecode-*.dist-info + +%changelog + diff --git a/.github/workflows/rpmbuild.yml b/.github/workflows/rpmbuild.yml new file mode 100644 index 00000000..906d034a --- /dev/null +++ b/.github/workflows/rpmbuild.yml @@ -0,0 +1,32 @@ +name: RPM build + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build_rpm: + if: ${{ github.event.base_ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set release version env + run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_REF + + - name: Create source archive + run: > + cd .. + && tar -czf python-bytecode.tar.gz bytecode + && mv python-bytecode.tar.gz bytecode/.github/actions/buildrpm + + - name: Build RPM package + id: rpm + uses: ./.github/actions/buildrpm + + - name: Upload RPM as artifact + uses: actions/upload-artifact@v4 + with: + name: python-bytecode-binary-rpm-${{ env.RELEASE_VERSION }} + path: ${{ github.workspace }}/*.rpm