Skip to content

Commit 27261d3

Browse files
authored
build: mirrored publish to d.py-interactions and interactions.py (#1336)
1 parent c731141 commit 27261d3

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed
Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
name: Publish release
1+
name: Publish to PyPI under the mirrored and original name
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
env:
9+
PACKAGE_NAME1: discord-py-interactions
10+
PACKAGE_NAME2: interactions.py
11+
212
jobs:
3-
deploy:
4-
name: Deploy
13+
build-and-publish:
514
runs-on: ubuntu-latest
15+
if: "!github.event.release.prerelease"
616
steps:
7-
- uses: actions/checkout@v2
17+
- name: Check out repository
18+
uses: actions/checkout@v2
19+
820
- name: Set up Python
921
uses: actions/setup-python@v2
1022
with:
11-
python-version: '3.x'
23+
python-version: '3.10'
24+
1225
- name: Install dependencies
1326
run: |
1427
python -m pip install --upgrade pip
15-
pip install setuptools wheel twine
16-
- name: Build and publish
28+
pip install build twine
29+
30+
- name: Build and publish packages
1731
env:
18-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
19-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
2033
run: |
21-
python setup.py sdist bdist_wheel
22-
twine upload dist/*
23-
on:
24-
release:
25-
types: [released]
34+
for PACKAGE_NAME in $PACKAGE_NAME1 $PACKAGE_NAME2; do
35+
sed -i "s/name=.*,/name=\"$PACKAGE_NAME\",/" setup.py
36+
python -m build --outdir dist/$PACKAGE_NAME
37+
python -m twine upload --skip-existing -u __token__ -p $PYPI_API_TOKEN dist/$PACKAGE_NAME/*
38+
done

interactions/client/const.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import os
3939
import sys
4040
from collections import defaultdict
41-
from importlib.metadata import version as _v
41+
from importlib.metadata import version as _v, PackageNotFoundError
4242
from typing import TypeVar, Union, Callable, Coroutine
4343

4444
__all__ = (
@@ -82,10 +82,15 @@
8282

8383
_ver_info = sys.version_info
8484

85-
try:
86-
__version__ = _v("interactions")
87-
except Exception:
88-
__version__ = "0.0.0"
85+
repo_names = ("interactions.py", "discord-py-interactions")
86+
for repo_name in repo_names:
87+
try:
88+
__version__ = _v(repo_name)
89+
break
90+
except PackageNotFoundError:
91+
__version__ = "0.0.0"
92+
93+
8994
__repo_url__ = "https://github.com/interactions-py/interactions.py"
9095
__py_version__ = f"{_ver_info[0]}.{_ver_info[1]}"
9196
__api_version__ = 10

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.poetry]
2-
name = "discord-py-interactions"
2+
name = "interactions.py"
33
version = "5.0.0"
44
description = "Easy, simple, scalable and modular: a Python API wrapper for interactions."
55
authors = [

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
extras_require["dev"] = extras_require["tests"] + extras_require["docs"] + ["pre-commit"]
3636

3737
setup(
38-
name="discord-py-interactions",
38+
name="interactions.py",
3939
description=pyproject["tool"]["poetry"]["description"],
4040
long_description=(Path(__file__).parent / "README.md").read_text(),
4141
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)