Skip to content

Commit b04c867

Browse files
Rework GitHub Actions to correctly and sanely push to PyPi in a controlled manner (#456)
* begin OIDC pypi publishing * cleanup actions * build extras * remove cibw * build extras * unique artifact names * force an update first
1 parent cc3ad33 commit b04c867

File tree

5 files changed

+74
-100
lines changed

5 files changed

+74
-100
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
types: [opened, edited, synchronize]
77

88
jobs:
9-
lib:
9+
build:
10+
name: Build wheels
1011
runs-on: ubuntu-latest
1112
strategy:
1213
fail-fast: false
@@ -15,34 +16,51 @@ jobs:
1516

1617
steps:
1718
- name: Checkout
18-
uses: actions/checkout@v2
19+
uses: actions/checkout@v4
1920
with:
2021
fetch-depth: 0
2122

2223
- name: Install CPython
23-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v5
2425
with:
25-
python-version: ${{matrix.python-version}}
26+
python-version: ${{ matrix.python-version }}
2627

27-
- name: Install Deps
28+
- name: Install deps
2829
run: |
29-
python -m ensurepip
30-
pip install wheel setuptools
31-
pip install -r requirements.txt
30+
pip install -U wheel setuptools pip Cython
31+
pip install '.[speed,sound]'
3232
33-
- name: Build
34-
run: python setup.py sdist bdist_wheel
33+
- name: Build wheels
34+
run: pip wheel -w ./wheelhouse/ '.[speed,sound]'
35+
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: artifact-wheels-${{ matrix.python-version }}
39+
path: ./wheelhouse/twitchio*.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"
3553

3654
docs:
3755
runs-on: ubuntu-latest
3856
steps:
3957
- name: Checkout
40-
uses: actions/checkout@v2
58+
uses: actions/checkout@v4
4159
with:
4260
fetch-depth: 0
4361

4462
- name: Install CPython
45-
uses: actions/setup-python@v2
63+
uses: actions/setup-python@v5
4664
with:
4765
python-version: 3.7
4866

@@ -62,19 +80,41 @@ jobs:
6280
lint:
6381
runs-on: ubuntu-latest
6482
steps:
65-
- name: checkout
66-
uses: actions/checkout@v2
67-
68-
- name: Setup Python
69-
uses: actions/setup-python@v2
70-
with:
71-
python-version: 3.7
72-
73-
- name: install black
74-
run: |
75-
python -m ensurepip
76-
pip install black
77-
78-
- name: run linter
79-
run: |
80-
black twitchio --line-length 120 --verbose --check
83+
- name: checkout
84+
uses: actions/checkout@v4
85+
86+
- name: Setup Python
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: 3.7
90+
91+
- name: install black
92+
run: |
93+
python -m ensurepip
94+
pip install black
95+
96+
- name: run linter
97+
run: |
98+
black twitchio --line-length 120 --verbose --check
99+
100+
upload_pypi:
101+
if: github.event_name == 'push' && github.ref_type == 'tag'
102+
name: Publish built wheels to Pypi
103+
runs-on: ubuntu-latest
104+
environment: release
105+
needs: [build, sdist]
106+
permissions:
107+
id-token: write
108+
109+
steps:
110+
- uses: actions/download-artifact@v4
111+
112+
- name: Copy artifacts to dist/ folder
113+
run: |
114+
find . -name 'artifact-*' -exec unzip '{}' \;
115+
mkdir -p dist/
116+
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
117+
find . -name '*.whl' -exec mv '{}' dist/ \;
118+
119+
- uses: pypa/gh-action-pypi-publish@release/v1
120+
name: Publish to PyPI

.github/workflows/edit_version.py

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

.github/workflows/get_revision.py

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

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)