Skip to content

Commit 2ac7738

Browse files
authored
Merge pull request #3 from mrcaique/build_rpm_ci
Added workflow to build and upload a RPM file whenever a new release tag is created on main branch.
2 parents bf97d4c + 4ee8cb2 commit 2ac7738

5 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM opensuse/tumbleweed:latest
2+
3+
# Update
4+
RUN zypper patch -y
5+
6+
# Install necessary packages
7+
RUN zypper in -y \
8+
rpm-build rpmdevtools dnf-plugins-core python3 git gcc fdupes \
9+
python311-pip python311-setuptools python311-setuptools_scm python311-wheel \
10+
python312-pip python312-setuptools python312-setuptools_scm python312-wheel \
11+
python313-pip python313-setuptools python313-setuptools_scm python313-wheel
12+
13+
WORKDIR /usr/src/packages
14+
15+
# Copy necessary files to build a rpm package
16+
COPY python-bytecode.spec SPECS/
17+
COPY python-bytecode.tar.gz SOURCES/
18+
19+
# Set up the entrypoint script
20+
COPY entrypoint.sh /entrypoint.sh
21+
RUN chmod +x /entrypoint.sh
22+
23+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Build RPM"
2+
description: "Build RPM package"
3+
4+
outputs:
5+
rpm-package:
6+
description: "Bytecode is a Python module to generate and modify bytecode"
7+
8+
runs:
9+
using: "docker"
10+
image: "Dockerfile"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
cd /usr/src/packages
3+
4+
# Update release verion on spec file
5+
sed -i -e "s/##RPMVERSION##/$RELEASE_VERSION/" SPECS/python-bytecode.spec
6+
7+
rpmbuild -bb SPECS/python-bytecode.spec
8+
mv RPMS/noarch/*.rpm $GITHUB_WORKSPACE
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# spec file for package python-bytecode
3+
#
4+
# Copyright (c) 2025 SUSE LLC
5+
#
6+
# All modifications and additions to the file contributed by third parties
7+
# remain the property of their copyright owners, unless otherwise agreed
8+
# upon. The license for this file, and modifications and additions to the
9+
# file, is the same license as for the pristine package itself (unless the
10+
# license for the pristine package is not an Open Source License, in which
11+
# case the license is the MIT License). An "Open Source License" is a
12+
# license that conforms to the Open Source Definition (Version 1.9)
13+
# published by the Open Source Initiative.
14+
15+
# Please submit bugfixes or comments via https://bugs.opensuse.org/
16+
#
17+
18+
19+
Name: python-bytecode
20+
Version: ##RPMVERSION##
21+
Release: 1%{?dist}
22+
Summary: Python module to generate and modify bytecode
23+
License: MIT
24+
URL: https://github.com/mrcaique/bytecode
25+
Source: /github/home/rpmbuild/SOURCES/%{name}.tar.gz
26+
BuildRequires: python-rpm-macros
27+
BuildRequires: %{python_module pip}
28+
BuildRequires: %{python_module setuptools >= 61.2}
29+
BuildRequires: %{python_module setuptools_scm >= 3.4.3}
30+
BuildRequires: %{python_module wheel}
31+
BuildRequires: fdupes
32+
BuildArch: noarch
33+
%python_subpackages
34+
35+
%description
36+
Python module to generate and modify bytecode
37+
38+
%prep
39+
%autosetup -p1 -n bytecode
40+
41+
%build
42+
%pyproject_wheel
43+
44+
%install
45+
%pyproject_install
46+
%python_expand %fdupes %{buildroot}%{$python_sitelib}
47+
48+
%files %{python_files}
49+
%doc README.rst
50+
%license COPYING
51+
%{python_sitelib}/bytecode
52+
%{python_sitelib}/bytecode-*.dist-info
53+
54+
%changelog
55+

.github/workflows/rpmbuild.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: RPM build
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build_rpm:
10+
if: ${{ github.event.base_ref == 'refs/heads/main' }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set release version env
16+
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_REF
17+
18+
- name: Create source archive
19+
run: >
20+
cd ..
21+
&& tar -czf python-bytecode.tar.gz bytecode
22+
&& mv python-bytecode.tar.gz bytecode/.github/actions/buildrpm
23+
24+
- name: Build RPM package
25+
id: rpm
26+
uses: ./.github/actions/buildrpm
27+
28+
- name: Upload RPM as artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: python-bytecode-binary-rpm-${{ env.RELEASE_VERSION }}
32+
path: ${{ github.workspace }}/*.rpm

0 commit comments

Comments
 (0)