Generate default LL server config and attach it to GH release (#6430)

This commit is contained in:
Jakub Kuczys
2024-08-26 19:34:37 +02:00
committed by GitHub
parent 68f2806204
commit 90691ba2b9
9 changed files with 431 additions and 283 deletions

View File

@@ -80,10 +80,38 @@ jobs:
name: build-output
path: ./dist
generate_default_ll_server_config:
name: Generate default application.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install script's dependencies
run: python -m pip install PyYAML
- name: Generate default application.yml
env:
APP_YML_FILE: "Red-DiscordBot-${{ github.ref_name }}-default-lavalink-application.yml"
run: |
mkdir -p dist
python .github/workflows/scripts/get_default_ll_server_config.py "dist/$APP_YML_FILE"
- name: Upload default application.yml
uses: actions/upload-artifact@v3
with:
name: ll-default-server-config
path: ./dist
release_to_pypi:
needs:
- release_information
- build
- generate_default_ll_server_config
environment: Release
name: Release to PyPI
runs-on: ubuntu-latest
@@ -96,6 +124,18 @@ jobs:
name: build-output
path: dist/
- name: Download default application.yml
uses: actions/download-artifact@v3
with:
name: ll-default-server-config
path: dist/
- name: Upload dists to GitHub Release
env:
GITHUB_TOKEN: "${{ github.token }}"
run: |
gh release upload "$GITHUB_REF_NAME" dist/*
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:

View File

@@ -0,0 +1,31 @@
import sys
from pathlib import Path
import yaml
ROOT_FOLDER = Path(__file__).parents[3].absolute()
AUDIO_FOLDER = ROOT_FOLDER / "redbot/cogs/audio"
# We want to import `redbot.cogs.audio.managed_node` package as if it were top-level package
# so we have to the `redbot/cogs/audio` directory to Python's path.
sys.path.insert(0, str(AUDIO_FOLDER))
def main() -> int:
try:
output_file = sys.argv[1]
except IndexError:
print("Usage:", sys.argv[0], "<output_file>", file=sys.stderr)
return 2
import managed_node
server_config = managed_node.get_default_server_config()
with open(output_file, "w", encoding="utf-8") as fp:
yaml.safe_dump(server_config, fp)
return 0
if __name__ == "__main__":
raise SystemExit(main())