Skip to content

Commit

Permalink
add rpm build rules according to badfish example (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleneum committed Feb 24, 2022
1 parent 153e970 commit d957748
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/push-copr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: RPM build in Fedora Copr

# build new transitions rpms only when tagged or when working on dev-rpm
on:
push:
branches:
- "dev-rpm"
tags:
- '*'

jobs:
build:
name: Submit a build from Fedora container
container: fedora:latest
runs-on: ubuntu-latest

steps:
- name: Check out proper version of sources
uses: actions/checkout@v1

- name: Install API token for copr-cli
env:
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
run: |
mkdir -p "$HOME/.config"
echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr"
- name: Install tooling for source RPM build
run: |
dnf -y install @development-tools @rpm-development-tools copr-cli make
- name: Build the source RPM
run: |
cd rpm && chmod +x ./build-helper && make srpm
- name: Submit the build by uploading the source RPM
run: |
copr build aleneum/python3-transitions rpm/*.src.rpm
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Build Status](https://github.com/pytransitions/transitions/actions/workflows/pytest.yml/badge.svg)](https://github.com/pytransitions/transitions/actions?query=workflow%3Apytest)
[![Coverage Status](https://coveralls.io/repos/pytransitions/transitions/badge.svg?branch=master&service=github)](https://coveralls.io/github/pytransitions/transitions?branch=master)
[![PyPi](https://img.shields.io/pypi/v/transitions.svg)](https://pypi.org/project/transitions)
[![Copr build status](https://copr.fedorainfracloud.org/coprs/aleneum/python3-transitions/package/python3-transitions/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/aleneum/python3-transitions/package/python3-transitions/)
[![GitHub commits](https://img.shields.io/github/commits-since/pytransitions/transitions/0.8.11.svg)](https://github.com/pytransitions/transitions/compare/0.8.11...master)
[![License](https://img.shields.io/github/license/pytransitions/transitions.svg)](LICENSE)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/pytransitions/transitions/master?filepath=examples%2FPlayground.ipynb)
Expand Down
5 changes: 5 additions & 0 deletions rpm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.spec
*.tar.gz
*.src.rpm
noarch/
python3-transitions.spec/
36 changes: 36 additions & 0 deletions rpm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PYTHON := python3
BUILD_HELPER := ./build-helper

VERSION = $(shell $(BUILD_HELPER) --version)
RELEASE = $(shell $(BUILD_HELPER) --release)
DATE = $(shell date +'%a %b %d %Y')
TARBALL = python3-transitions-$(VERSION).tar.gz

all: python3-transitions.spec python3-transitions-$(VERSION).tar.gz

.PHONY: $(TARBALL)
$(TARBALL):
rm -f $(TARBALL)
( cd .. && git archive --prefix python3-transitions-$(VERSION)/ HEAD ) \
| gzip > "$@"

python3-transitions.spec: python3-transitions.spec.tpl ../setup.py
@echo " GEN $@" ; \
sed -e "s|@VERSION@|$(VERSION)|g" \
-e "s|@RELEASE@|$(RELEASE)|g" \
-e "s|@DATE@|$(DATE)|g" \
$< > $@.output ; \
mv "$@.output" "$@" # move when successful

srpm: all
dir=`pwd` ; \
rm -f *.src.rpm ; \
rpmbuild --define "_sourcedir $$dir" \
--define "_rpmdir $$dir" \
--define "_builddir $$dir" \
--define "_specdir $$dir" \
--define "_srcrpmdir $$dir" \
-bs *.spec

clean:
rm -rf *.src.rpm *.tar.gz *.spec noarch
10 changes: 10 additions & 0 deletions rpm/build-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/sh

case $1 in
--version)
cd .. ; ${PYTHON-python3} setup.py --version
;;
--release)
echo "git.$(date +"%Y%m%d_%H%M%S")"
;;
esac
39 changes: 39 additions & 0 deletions rpm/python3-transitions.spec.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%global sum A lightweight, object-oriented finite state machine implementation in Python with many extensions
%global desc \
A lightweight, object-oriented state machine implementation in Python with many extensions. \
Compatible with Python 2.7+ and 3.0+.


Name: python3-transitions
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: %{sum}

License: MIT
URL: https://github.com/pytransitions/transitions
Source0: %{url}/archive/v%{version}/python3-transitions-%{version}.tar.gz

BuildArch: noarch
BuildRequires: python3-setuptools
BuildRequires: python3-devel

%description
%{desc}

%prep
%autosetup -n %{name}-%{version}

%build
%py3_build

%install
%py3_install

%files -n %{name}
%doc README.md
%license LICENSE
%{python3_sitelib}/*

%changelog
* @DATE@ Alexander Neumann <aleneum@gmail.com> - @VERSION@-@RELEASE@
- built from upstream, changelog ignored

0 comments on commit d957748

Please sign in to comment.