Browse Source

Initial implementation of automatic renamed branch syncing

pull/10109/head
dolfies 3 years ago
parent
commit
6897e9134e
  1. 58
      .github/files/README.rst
  2. 34
      .github/workflows/rename.yml
  3. 28
      .github/workflows/scripts/close_and_reopen_pr.js
  4. 5
      README.rst
  5. 8
      setup.py

58
.github/files/README.rst

@ -0,0 +1,58 @@
selfcord.py
===========
.. image:: https://img.shields.io/endpoint?url=https%3A%2F%2Frunkit.io%2Fdamiankrawczyk%2Ftelegram-badge%2Fbranches%2Fmaster%3Furl%3Dhttps%3A%2F%2Ft.me%2Fdpy_self
:target: https://t.me/dpy_self
:alt: Telegram chat
.. image:: https://img.shields.io/pypi/v/discord.py-self.svg
:target: https://pypi.python.org/pypi/discord.py-self
:alt: PyPI version info
.. image:: https://img.shields.io/pypi/pyversions/discord.py.svg
:target: https://pypi.python.org/pypi/discord.py-self
:alt: PyPI supported Python versions
.. image:: https://img.shields.io/pypi/dm/discord.py-self.svg
:target: https://pypi.python.org/pypi/discord.py-self
:alt: PyPI downloads per month
A modern, easy to use, feature-rich, and async ready API wrapper for Discord's user API written in Python.
Notice
-------
This branch is just a copy of regular ``discord.py-self`` with the import name changed to ``selfcord``, so ``discord.py-self`` can be used alongside upstream ``discord.py``. Check out the `master branch <https://github.com/dolfies/discord.py-self>`_ for more information. Use of this branch is not recommended, and should only be used if you are using both ``discord.py`` and ``discord.py-self`` in the same *project*. Otherwise, utilize virtual environments to seperate the installs of the two libraries.
This library is 100% compatible with regular ``discord.py-self``, and any documentation, examples, etc. need only the import name changed.
Installing
----------
**Python 3.8 or higher is required**
This branch is synced with the master branch on every commit. Because of this, the branch always hosts the current development version.
Because of this, it is *highly* recommended to pin your installation to a certain commit. You can do this like so:
.. code:: sh
# Linux/macOS
python3 -m pip install git+https://github.com/dolfies/discord.py-self@2193ws21sf4cs74hdg317ac8ad076ed234d3dbf70g1#egg=selfcord.py[voice]
# Windows
py -3 -m pip install git+https://github.com/dolfies/discord.py-self@2193ws21sf4cs74hdg317ac8ad076ed234d3dbf70g1#egg=selfcord.py[voice]
Otherwise, you can install the current commit:
.. code:: sh
# Linux/macOS
python3 -m pip install git+https://github.com/dolfies/discord.py-self@renamed#egg=selfcord.py[voice]
# Windows
py -3 -m pip install git+https://github.com/dolfies/discord.py-self@renamed#egg=selfcord.py[voice]
Links
------
- `Documentation <https://discordpy-self.readthedocs.io/en/latest/index.html>`_
- `Project updates <https://t.me/dpy_self>`_
- `Discussion & support <https://t.me/dpy_self_discussions>`_

34
.github/workflows/rename.yml

@ -0,0 +1,34 @@
name: rename
on:
workflow_dispatch:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Replace instances
run: |
cp .github/files/README.rst README.rst
rm -rf docs .github .readthedocs.yml
mv discord selfcord
sed -i -e 's/import discord/import selfcord/g' -e 's/from discord/from selfcord/g' -e 's/from discord/from selfcord/g' -e 's/discord\.py-self/selfcord\.py/g' -e '/\(discord\.com\|discord\.gg\|discord\.new\)/! s/discord\./selfcord\./g' $(find selfcord examples tests -name "*.py")
sed -i -e 's/discord/selfcord/g' pyproject.toml MANIFEST.in
sed -i -e "s/prefix = 'discord'/prefix = 'selfcord'/" setup.py
- name: Push changes
uses: actions-x/commit@v6
with:
message: Synchronize selfcord
branch: renamed
force: true

28
.github/workflows/scripts/close_and_reopen_pr.js

@ -1,28 +0,0 @@
module.exports = (async function ({github, context}) {
const pr_number = process.env.PR_NUMBER;
const pr_operation = process.env.PR_OPERATION;
if (!['created', 'updated'].includes(pr_operation)) {
console.log('PR was not created as there were no changes.')
return;
}
// Close the PR
github.issues.update({
issue_number: pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
// Wait a moment for GitHub to process it...
await new Promise(r => setTimeout(r, 2000));
// Then reopen the PR so it runs CI
github.issues.update({
issue_number: pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
})

5
README.rst

@ -82,6 +82,11 @@ Please note that on Linux installing voice you must install the following packag
* libffi-dev (or ``libffi-devel`` on some systems) * libffi-dev (or ``libffi-devel`` on some systems)
* python-dev (e.g. ``python3.6-dev`` for Python 3.6) * python-dev (e.g. ``python3.6-dev`` for Python 3.6)
Using with Upstream
~~~~~~~~~~~~~~~~~~~~
If you would like to use the library alongside upstream ``discord.py``, you can install ``selfcord.py`` instead of ``discord.py-self``. Check out the `renamed branch <https://github.com/dolfies/discord.py-self/tree/renamed>`_ for more information.
Quick Example Quick Example
-------------- --------------

8
setup.py

@ -1,12 +1,14 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
import re import re
prefix = 'discord' # This will be changed with regular expressions if necessary
requirements = [] requirements = []
with open('requirements.txt') as f: with open('requirements.txt') as f:
requirements = f.read().splitlines() requirements = f.read().splitlines()
version = '' version = ''
with open('discord/__init__.py') as f: with open(f'{prefix}/__init__.py') as f:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1)
if not version: if not version:
@ -49,7 +51,7 @@ extras_require = {
} }
setup( setup(
name='discord.py-self', name='discord.py-self' if prefix == 'discord' else f'{prefix}.py',
author='Dolfies', author='Dolfies',
url='https://github.com/dolfies/discord.py-self', url='https://github.com/dolfies/discord.py-self',
project_urls={ project_urls={
@ -59,7 +61,7 @@ setup(
"Discussion & support": "https://t.me/dpy_self_discussions", "Discussion & support": "https://t.me/dpy_self_discussions",
}, },
version=version, version=version,
packages=find_packages() + ['discord.ext.commands', 'discord.ext.tasks'], packages=find_packages() + [f'{prefix}.ext.commands', f'{prefix}.ext.tasks'],
license='MIT', license='MIT',
description='A Python wrapper for the Discord user API', description='A Python wrapper for the Discord user API',
long_description=readme, long_description=readme,

Loading…
Cancel
Save