generated from GrafeasGroup/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from GrafeasGroup/packaging
PACKAGING!
- Loading branch information
Showing
40 changed files
with
848 additions
and
1,202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10.x' | ||
- name: Install Env | ||
# shiv will download the dependencies it needs on its own | ||
run: | | ||
pip install --upgrade pip | ||
pip install shiv | ||
pip install poetry | ||
pip install poetry2setup | ||
- name: Add CURRENT_TIME env property | ||
# the smart thing to do here would be to use the commit hash, but | ||
# github releases are ALPHABETIZED, so a commit hash of `abcdef` will | ||
# not be listed as the latest release if `defabc` came before. (╥﹏╥) | ||
run: echo "CURRENT_TIME_VERSION=v$(date '+%s')" >> $GITHUB_ENV | ||
- name: Build the sucker | ||
run: | | ||
sed -i -e "s/?????/${{ env.CURRENT_TIME_VERSION }}/g" bubbles/__init__.py | ||
make build | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "build/bubbles.pyz" | ||
body: "It's releasin' time" | ||
generateReleaseNotes: true | ||
tag: ${{ env.CURRENT_TIME_VERSION }} | ||
commit: master | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build bubbles.pyz and test | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10.x' | ||
- name: Install Env | ||
# shiv will download the dependencies it needs on its own | ||
run: | | ||
pip install --upgrade pip | ||
pip install shiv | ||
pip install poetry | ||
pip install poetry2setup | ||
- name: Add CURRENT_TIME env property | ||
# the smart thing to do here would be to use the commit hash, but | ||
# github releases are ALPHABETIZED, so a commit hash of `abcdef` will | ||
# not be listed as the latest release if `defabc` came before. (╥﹏╥) | ||
run: echo "CURRENT_TIME_VERSION=v$(date '+%s')" >> $GITHUB_ENV | ||
- name: Build the sucker | ||
run: | | ||
sed -i -e "s/?????/${{ env.CURRENT_TIME_VERSION }}/g" bubbles/__init__.py | ||
make build | ||
- name: Remove source to make sure it doesn't interfere with the tests | ||
run: rm -rf bubbles/ | ||
- name: Run selfcheck on compiled binary | ||
run: ./build/bubbles.pyz selfcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,3 +114,7 @@ presence_log.json | |
|
||
asdf.py | ||
test.py | ||
|
||
# build artifacts | ||
bubbles.pyz | ||
setup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
setup: | ||
poetry2setup > setup.py | ||
|
||
build: setup shiv | ||
|
||
clean: | ||
rm setup.py | ||
|
||
shiv: | ||
mkdir -p build | ||
shiv -c bubbles -o build/bubbles.pyz . --compressed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
# Don't touch! | ||
# This actually enables loading all the files in the commands subdirectory and | ||
# works alongside bubbles.commands.__init__ | ||
from bubbles.commands import * | ||
__version__ = "?????" # This is populated by the CI pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
""" | ||
Automatically load all python files inside this directory. | ||
from dataclasses import dataclass, asdict | ||
from typing import Callable | ||
|
||
This allows the plugin manager to actually find everything! | ||
""" | ||
# source: https://stackoverflow.com/a/1057534 | ||
from typing import List, Union | ||
import glob | ||
from os.path import dirname, basename, isfile, join | ||
|
||
from bubbles.config import PluginManager | ||
@dataclass | ||
class Plugin: | ||
callable: Callable | ||
regex: str | ||
flags: int = None | ||
callback: Callable = None | ||
ignore_prefix: bool = False | ||
help: str = None | ||
interactive_friendly: bool = True | ||
|
||
modules = glob.glob(join(dirname(__file__), "*.py")) | ||
__all__ = [ | ||
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith("__init__.py") | ||
] | ||
|
||
|
||
def clean_text(text: Union[str, List]) -> str: | ||
""" | ||
Take the trigger word out of the text. | ||
Examples: | ||
!test -> !test | ||
!test one -> !test one | ||
@bubbles test -> test | ||
@bubbles test one -> test one | ||
""" | ||
if isinstance(text, list): | ||
text = " ".join(text) | ||
|
||
return PluginManager.try_get_command_text(text) or text | ||
def to_dict(self): | ||
return asdict(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.