feat: introduce CI/CD workflow and packaging setup
Added Forgejo Actions workflow for Python package CI/CD, enabling automated testing and deployment to PyPI upon new tags. Introduced README and LICENSE files to document and license the project. Set up project with pyproject.toml, specifying dependencies, build system, and scripts. Configured .gitignore to exclude build artifacts. Helps automate deployment and set a structured foundation for the project.
This commit is contained in:
parent
cfd985a746
commit
6d62dc99c8
7 changed files with 174 additions and 1 deletions
54
.forgejo/workflows/release.yml
Normal file
54
.forgejo/workflows/release.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
name: Python Package CI/CD
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Setup and Test
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update
|
||||
apt install -y python3-venv
|
||||
|
||||
- name: Set up Python environment
|
||||
run: |
|
||||
python3 -V
|
||||
python3 -m venv venv
|
||||
. ./venv/bin/activate
|
||||
pip install -U pip
|
||||
pip install .[all]
|
||||
|
||||
publish:
|
||||
name: Publish to PyPI
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update
|
||||
apt install -y python3-venv
|
||||
|
||||
- name: Publish to PyPI
|
||||
run: |
|
||||
python3 -m venv venv
|
||||
. ./venv/bin/activate
|
||||
pip install -U hatchling twine build
|
||||
python -m build .
|
||||
python -m twine upload --username __token__ --password ${PYPI_TOKEN} dist/*
|
||||
env:
|
||||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ venv/
|
|||
__pycache__/
|
||||
*.pyc
|
||||
config.yaml
|
||||
dist/
|
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2024 Private.coffee Team <support@private.coffee>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
59
README.md
Normal file
59
README.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Matrix-Roomba
|
||||
|
||||
[![Support Private.coffee!](https://shields.private.coffee/badge/private.coffee-support%20us!-pink?logo=coffeescript)](https://private.coffee)
|
||||
[![PyPI](https://shields.private.coffee/pypi/v/matrix-roomba)](https://pypi.org/project/matrix-roomba/)
|
||||
[![PyPI - Python Version](https://shields.private.coffee/pypi/pyversions/matrix-roomba)](https://pypi.org/project/matrix-roomba/)
|
||||
[![PyPI - License](https://shields.private.coffee/pypi/l/matrix-roomba)](https://pypi.org/project/matrix-roomba/)
|
||||
[![Latest Git Commit](https://shields.private.coffee/gitea/last-commit/privatecoffee/matrix-roomba?gitea_url=https://git.private.coffee)](https://git.private.coffee/privatecoffee/matrix-roomba)
|
||||
|
||||
Roomba is a moderation bot for Matrix, designed to help manage rooms and enforce content policies. The bot can block/unblock rooms, shut down rooms, and notify users of shutdowns. It integrates with Synapse's administrative API and supports optional encryption through Pantalaimon.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install matrix-roomba
|
||||
```
|
||||
|
||||
Create a configuration file in `config.yaml` based on the [config.dist.yaml](config.dist.yaml) provided in the repository.
|
||||
|
||||
At the very least, you need to provide the following configuration:
|
||||
|
||||
```yaml
|
||||
homeserver: "https://matrix.example.com"
|
||||
user_id: "@roomba:example.com"
|
||||
access_token: "YOUR_ACCESS_TOKEN"
|
||||
moderation_room_id: "!moderation_room_id:example.com"
|
||||
```
|
||||
|
||||
Ensure that the bot user is an admin on the homeserver, as it needs to be able to moderate rooms. Also add the user to the moderation room before starting the bot.
|
||||
|
||||
We recommend using pantalaimon as a proxy, because the bot itself does not support end-to-end encryption.
|
||||
|
||||
You can start the bot by running:
|
||||
|
||||
## Usage
|
||||
|
||||
1. Start the bot:
|
||||
|
||||
```bash
|
||||
roomba
|
||||
```
|
||||
|
||||
2. Send a message to the moderation room to get a list of available commands:
|
||||
|
||||
```
|
||||
!roomba
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
In the moderation room, send commands to manage rooms:
|
||||
|
||||
- Block a room: !roomba block <room_id>
|
||||
- Unblock a room: !roomba unblock <room_id>
|
||||
- Shutdown a room: !roomba shutdown <room_id> [--purge]
|
||||
- For help: !roomba
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
40
pyproject.toml
Normal file
40
pyproject.toml
Normal file
|
@ -0,0 +1,40 @@
|
|||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[project]
|
||||
name = "matrix-roomba"
|
||||
version = "0.1.0"
|
||||
|
||||
authors = [{ name = "Private.coffee Team", email = "support@private.coffee" }]
|
||||
|
||||
description = "A Matrix bot that helps you shut down rooms"
|
||||
readme = "README.md"
|
||||
license = { file = "LICENSE" }
|
||||
requires-python = ">=3.10"
|
||||
|
||||
packages = ["src/matrix_roomba"]
|
||||
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"matrix-nio",
|
||||
"pyyaml"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
"Homepage" = "https://git.private.coffee/PrivateCoffee/matrix-roomba"
|
||||
"Bug Tracker" = "https://git.private.coffee/PrivateCoffee/matrix-roomba/issues"
|
||||
|
||||
[project.scripts]
|
||||
roomba = "matrix_roomba.bot:main"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/matrix_roomba"]
|
0
src/matrix_roomba/__init__.py
Normal file
0
src/matrix_roomba/__init__.py
Normal file
Loading…
Reference in a new issue