Skip to content

Commit fba7acc

Browse files
committed
Automatically publish to PyPI and to Github
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
1 parent dce178d commit fba7acc

2 files changed

Lines changed: 121 additions & 48 deletions

File tree

.github/workflows/main.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
on:
2+
push:
3+
pull_request:
4+
5+
name: Tests & Release
6+
7+
jobs:
8+
tests-misc:
9+
name: Misc tests
10+
runs-on: ubuntu-latest
11+
container: fedorapython/fedora-python-tox:latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Install dependencies
15+
run: |
16+
dnf install -y git tox
17+
pip install poetry>=1.2
18+
- name: Mark the working directory as safe for Git
19+
run: git config --global --add safe.directory $PWD
20+
- name: Run tests
21+
run: tox -e ${{ matrix.tox_env }}
22+
strategy:
23+
matrix:
24+
tox_env:
25+
- lint
26+
- format
27+
28+
tests-unit:
29+
name: Unit tests
30+
runs-on: ubuntu-latest
31+
container: fedorapython/fedora-python-tox:latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Install dependencies
35+
run: |
36+
dnf install -y git tox
37+
pip install poetry>=1.2
38+
- name: Mark the working directory as safe for Git
39+
run: git config --global --add safe.directory $PWD
40+
- name: Run tests
41+
run: tox -e ${{ matrix.tox_env }},diff-cover
42+
strategy:
43+
matrix:
44+
tox_env:
45+
- py38
46+
- py39
47+
- py310
48+
- py311
49+
50+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
51+
build:
52+
name: Build distribution 📦
53+
runs-on: ubuntu-latest
54+
needs:
55+
- tests-unit
56+
- tests-misc
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Set up Python
60+
uses: actions/setup-python@v4
61+
with:
62+
python-version: "3.x"
63+
- name: Install pypa/build
64+
run: python3 -m pip install build --user
65+
- name: Build a binary wheel and a source tarball
66+
run: python3 -m build
67+
- name: Store the distribution packages
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
73+
publish-to-pypi:
74+
name: Publish to PyPI 🚀
75+
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') # only publish to PyPI on final tag pushes
76+
needs:
77+
- build
78+
runs-on: ubuntu-latest
79+
environment:
80+
name: pypi
81+
url: https://pypi.org/p/bugzilla2fedmsg-schema
82+
permissions:
83+
id-token: write # IMPORTANT: mandatory for trusted publishing
84+
steps:
85+
- name: Download all the dists
86+
uses: actions/download-artifact@v3
87+
with:
88+
name: python-package-distributions
89+
path: dist/
90+
- name: Publish distribution to PyPI
91+
uses: pypa/gh-action-pypi-publish@release/v1
92+
93+
github-release:
94+
name: Create a GitHub Release 📢
95+
needs:
96+
- publish-to-pypi
97+
runs-on: ubuntu-latest
98+
99+
permissions:
100+
contents: write # IMPORTANT: mandatory for making GitHub Releases
101+
id-token: write # IMPORTANT: mandatory for sigstore
102+
103+
steps:
104+
- name: Download all the dists
105+
uses: actions/download-artifact@v3
106+
with:
107+
name: python-package-distributions
108+
path: dist/
109+
- name: Sign the dists with Sigstore
110+
uses: sigstore/gh-action-sigstore-python@v2.1.0
111+
with:
112+
inputs: >-
113+
./dist/*.tar.gz
114+
./dist/*.whl
115+
- name: Release
116+
uses: softprops/action-gh-release@v1
117+
with:
118+
draft: true
119+
files: dist/*
120+
fail_on_unmatched_files: true
121+
generate_release_notes: true

.github/workflows/tests.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)