Skip to content

Update pre-commit hook psf/black to v26 #314

Update pre-commit hook psf/black to v26

Update pre-commit hook psf/black to v26 #314

Workflow file for this run

# SPDX-FileCopyrightText: Contributors to the Fedora Project
#
# SPDX-License-Identifier: LGPL-3.0-or-later
---
name: Test & Build
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
tests:
name: Run the tests
runs-on: ubuntu-latest
container: fedorapython/fedora-python-tox:latest
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: |
dnf install -y pre-commit git libpq-devel krb5-devel
pip install poetry
- name: Mark the working directory as safe for Git
run: git config --global --add safe.directory $PWD
- name: Run the tests
run: tox
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
build:
name: Build distribution 📦
runs-on: ubuntu-latest
needs:
- tests
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build
run: python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish to PyPI 🚀
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') # only on final tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/journal-to-fedora-messaging-messages
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
rpms:
name: Build RPMs 📦
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') # only on final tag pushes
needs:
- build
runs-on: ubuntu-latest
container: fedora:latest
steps:
- uses: actions/checkout@v6
- name: Install base dependencies
run: sudo dnf -y install git rpm-build
- name: Mark the working directory as safe for Git
run: git config --global --add safe.directory $PWD
- name: Download all the dists
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: .
- name: Build RPMs
run: |
mkdir rpmbuild
sudo dnf -y builddep *.spec; \
exitcode=11; while [ $exitcode -eq 11 ]; do \
rpmbuild -D "_topdir $(pwd)/rpmbuild" -D "_sourcedir $(pwd)" -D "_srcrpmdir $(pwd)/RPMS" -bd $(pwd)/*.spec && exitcode=$? || exitcode=$? ; \
sudo dnf -y builddep RPMS/*src.rpm; \
done
rm -f RPMS/*.buildreqs.nosrc.rpm
rpmbuild -D "_topdir $(pwd)/rpmbuild" -D "_sourcedir $(pwd)" -D "_rpmdir $(pwd)/RPMS" -D "_srcrpmdir $(pwd)/RPMS" -D "_rpmfilename %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm" -ba *.spec
ls -al . RPMS
- name: Store the RPMs
uses: actions/upload-artifact@v6
with:
name: rpms
path: RPMS
github-release:
name: Create a GitHub Release 📢
needs:
- publish-to-pypi
- rpms
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download the python package
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Download the RPMs
uses: actions/download-artifact@v7
with:
name: rpms
path: rpms/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.2.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*
rpms/*
fail_on_unmatched_files: true
generate_release_notes: true