Skip to content

Commit 21d04ca

Browse files
committed
Add workflows and setup.py
1 parent 1c3e767 commit 21d04ca

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, edited, synchronize]
7+
8+
jobs:
9+
build:
10+
name: Build wheels
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.11", "3.x"]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Install CPython
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install deps
29+
run: |
30+
pip install -U wheel setuptools pip Cython
31+
pip install -Ur requirements.txt
32+
33+
- name: Build wheels
34+
run: pip wheel -w ./wheelhouse/ .
35+
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: artifact-wheels-${{ matrix.python-version }}
39+
path: ./wheelhouse/twitchio-ext-oauth-relay*.whl
40+
41+
sdist:
42+
name: Make source distribution
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- run: pipx run build --sdist
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: artifact-source-dist
52+
path: "./**/dist/*.tar.gz"
53+
54+
lint:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
python-version: ["3.11", "3.x"]
60+
61+
name: "Type Coverage and Linting @ ${{ matrix.python-version }}"
62+
steps:
63+
- name: "Checkout Repository"
64+
uses: actions/checkout@v4
65+
with:
66+
fetch-depth: 0
67+
68+
- name: "Setup Python @ ${{ matrix.python-version }}"
69+
id: setup-python
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version: "${{ matrix.python-version }}"
73+
cache: "pip"
74+
75+
- name: "Install Python deps @ ${{ matrix.python-version }}"
76+
run: |
77+
pip install -Ur requirements.txt
78+
79+
- name: "Run Pyright @ ${{ matrix.python-version }}"
80+
uses: jakebailey/pyright-action@v2
81+
with:
82+
version: 1.1.398
83+
annotate: ${{ matrix.python-version != '3.x' }}
84+
warnings: false
85+
86+
- name: Lint with Ruff
87+
uses: astral-sh/ruff-action@v3
88+
with:
89+
version: "0.11.2"
90+
91+
- name: Check formatting with Ruff
92+
run: |
93+
ruff format --check
94+
95+
upload_pypi:
96+
if: github.event_name == 'push' && github.ref_type == 'tag'
97+
name: Publish built wheels to Pypi
98+
runs-on: ubuntu-latest
99+
environment: release
100+
needs: [build, sdist]
101+
permissions:
102+
id-token: write
103+
104+
steps:
105+
- uses: actions/download-artifact@v4
106+
107+
- name: Copy artifacts to dist/ folder
108+
run: |
109+
find . -name 'artifact-*' -exec unzip '{}' \;
110+
mkdir -p dist/
111+
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
112+
find . -name '*.whl' -exec mv '{}' dist/ \;
113+
114+
- uses: pypa/gh-action-pypi-publish@release/v1
115+
name: Publish to PyPI

.github/workflows/signoff.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: validate-signoff
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: PR Description Check
13+
uses: pythonistaguild/[email protected]
14+
with:
15+
content: "[x] I have read and agree to the [Developer Certificate of Origin]"

setup.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import re
2+
3+
from setuptools import setup # type: ignore
4+
5+
6+
def get_version() -> str:
7+
version = ""
8+
with open("twitchio/ext/oauth_relay/__init__.py") as f:
9+
match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
10+
11+
if not match or not match.group(1):
12+
raise RuntimeError("Version is not set")
13+
14+
version = match.group(1)
15+
16+
if version.endswith(("dev", "a", "b", "rc")):
17+
# append version identifier based on commit count
18+
try:
19+
import subprocess
20+
21+
p = subprocess.Popen(["git", "rev-list", "--count", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
22+
out, _ = p.communicate()
23+
if out:
24+
version += out.decode("utf-8").strip()
25+
except Exception:
26+
pass
27+
28+
return version
29+
30+
31+
setup(version=get_version())

0 commit comments

Comments
 (0)