From 7a1a605d4765f86a8c947751e5a71de9330256c2 Mon Sep 17 00:00:00 2001 From: marksie1988 Date: Fri, 31 May 2024 10:40:54 +0100 Subject: [PATCH] chore: redo CI to be more automated --- .devcontainer/Dockerfile | 10 +-- .devcontainer/devcontainer.json | 69 ++++++++++++++++++ ...-docker-compose.yml => docker-compose.yml} | 48 ++++++------ .devcontainer/example-env | 8 -- .devcontainer/recommended-devcontainer.json | 61 ---------------- .github/release.yml | 27 ------- .github/workflows/check-version.yml | 32 -------- .github/workflows/coverage.yml | 4 +- .github/workflows/docs.yml | 38 ++++++++++ .github/workflows/publish-docs.yml | 23 ------ .github/workflows/release.yml | 73 +++++++++++-------- .github/workflows/release.yml.old | 70 ++++++++++++++++++ .github/workflows/test.yml | 5 +- .gitignore | 7 -- .releaserc | 54 ++++++++++++++ {sphinx-docs => docs}/Makefile | 0 {sphinx-docs => docs}/conf.py | 0 {sphinx-docs => docs}/contributing.rst | 0 {sphinx-docs => docs}/index.rst | 0 {sphinx-docs => docs}/installing.rst | 0 {sphinx-docs => docs}/make.bat | 70 +++++++++--------- {sphinx-docs => docs}/models/common.rst | 0 {sphinx-docs => docs}/models/lidarr.rst | 0 {sphinx-docs => docs}/models/radarr.rst | 0 {sphinx-docs => docs}/models/readarr.rst | 0 {sphinx-docs => docs}/models/sonarr.rst | 0 {sphinx-docs => docs}/modules/lidarr.rst | 0 {sphinx-docs => docs}/modules/radarr.rst | 0 {sphinx-docs => docs}/modules/readarr.rst | 0 {sphinx-docs => docs}/modules/sonarr.rst | 0 {sphinx-docs => docs}/quickstart.rst | 0 {sphinx-docs => docs}/requirements.txt | 0 {sphinx-docs => docs}/toc.rst | 0 noxfile.py | 31 ++++++-- 34 files changed, 366 insertions(+), 264 deletions(-) create mode 100644 .devcontainer/devcontainer.json rename .devcontainer/{recommended-docker-compose.yml => docker-compose.yml} (67%) delete mode 100644 .devcontainer/example-env delete mode 100644 .devcontainer/recommended-devcontainer.json delete mode 100644 .github/release.yml delete mode 100644 .github/workflows/check-version.yml create mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/publish-docs.yml create mode 100644 .github/workflows/release.yml.old create mode 100644 .releaserc rename {sphinx-docs => docs}/Makefile (100%) rename {sphinx-docs => docs}/conf.py (100%) rename {sphinx-docs => docs}/contributing.rst (100%) rename {sphinx-docs => docs}/index.rst (100%) rename {sphinx-docs => docs}/installing.rst (100%) rename {sphinx-docs => docs}/make.bat (95%) rename {sphinx-docs => docs}/models/common.rst (100%) rename {sphinx-docs => docs}/models/lidarr.rst (100%) rename {sphinx-docs => docs}/models/radarr.rst (100%) rename {sphinx-docs => docs}/models/readarr.rst (100%) rename {sphinx-docs => docs}/models/sonarr.rst (100%) rename {sphinx-docs => docs}/modules/lidarr.rst (100%) rename {sphinx-docs => docs}/modules/radarr.rst (100%) rename {sphinx-docs => docs}/modules/readarr.rst (100%) rename {sphinx-docs => docs}/modules/sonarr.rst (100%) rename {sphinx-docs => docs}/quickstart.rst (100%) rename {sphinx-docs => docs}/requirements.txt (100%) rename {sphinx-docs => docs}/toc.rst (100%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 29bf63f..7d7807d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,15 +5,13 @@ RUN apt update && apt upgrade -y RUN apt install -y zsh python3-sphinx # Poetry -ARG POETRY_VERSION="latest" -RUN if [ "$POETRY_VERSION" = "latest" ]; then su vscode -c "umask 0002 && sudo pip3 install poetry"; fi -RUN if [ "$POETRY_VERSION" != "none" && "$POETRY_VERSION" != "latest" ]; then su vscode -c "umask 0002 && sudo pip3 install poetry==$POETRY_VERSION"; fi +RUN su vscode -c "umask 0002 && sudo pip3 install poetry" # Nox -ARG NOX_VERSION="latest" -RUN if [ "$NOX_VERSION" = "latest" ]; then su vscode -c "umask 0002 && sudo pip3 install nox-poetry nox"; fi -RUN if [ "$NOX_VERSION" != "none" && "$POETRY_VERSION" != "latest" ]; then su vscode -c "umask 0002 && sudo pip3 install nox-poetry nox==$NOX_VERSION"; fi +RUN su vscode -c "umask 0002 && sudo pip3 install nox-poetry nox" RUN wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O - | zsh || true +RUN poetry congfig virtualenvs.in-project true + CMD ["zsh"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..69f0e88 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,69 @@ +{ + "name": "PyArr", + "dockerComposeFile": [ + "docker-compose.workspace.yml" + ], + "service": "pyarr-workspace", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "forwardPorts": [ + "sonarr:8989", + "radarr:7878", + "readarr:8787", + "lidarr:8686" + ], + "initializeCommand": "echo 'Hello World!'", + "customizations": { + "vscode": { + "settings": { + "[python]": { + "diffEditor.ignoreTrimWhitespace": false, + "editor.formatOnType": true, + "editor.wordBasedSuggestions": "off", + "editor.defaultFormatter": "ms-python.black-formatter", + "autoDocstring.docstringFormat": "google", + "editor.tabSize": 4 + }, + "[yaml]": { + "editor.insertSpaces": true, + "editor.tabSize": 2, + "editor.autoIndent": "advanced", + "diffEditor.ignoreTrimWhitespace": false + }, + "files.eol": "\n", + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + }, + "extensions": [ + "sourcery.sourcery", + "njpwerner.autodocstring", + "ms-python.flake8", + "dbaeumer.vscode-eslint", + "ms-python.isort", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.black-formatter", + "GitHub.vscode-github-actions", + "yzhang.markdown-all-in-one" + ], + "runArgs": [ + "--network=pyarr-dev" + ] + } + }, + "remoteUser": "vscode", + "postCreateCommand": "zsh ./.devcontainer/post-install.sh", + "mounts": [ + /* Re-use local SSH keys (useful if you use SSH keys for Git repo access or other SSH work)*/ + "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached", + /* Re-use local Git configuration*/ + "source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached", + ] +} diff --git a/.devcontainer/recommended-docker-compose.yml b/.devcontainer/docker-compose.yml similarity index 67% rename from .devcontainer/recommended-docker-compose.yml rename to .devcontainer/docker-compose.yml index 1f24493..f88a38b 100644 --- a/.devcontainer/recommended-docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -50,27 +50,27 @@ services: ports: - 8686:8686 restart: unless-stopped - deluge: - image: lscr.io/linuxserver/deluge:latest - container_name: deluge - environment: - - PUID=1000 - - PGID=1000 - - TZ=Europe/London - volumes: - - ../tests/docker_configs/deluge/config:/config - ports: - - 8112:8112 - restart: unless-stopped - jackett: - image: lscr.io/linuxserver/jackett:latest - container_name: jackett - environment: - - PUID=1000 - - PGID=1000 - - TZ=Europe/London - volumes: - - ../tests/docker_configs/jackett/config:/config - ports: - - 9117:9117 - restart: unless-stopped + #deluge: + # image: lscr.io/linuxserver/deluge:latest + # container_name: deluge + # environment: + # - PUID=1000 + # - PGID=1000 + # - TZ=Europe/London + # volumes: + # - ../tests/docker_configs/deluge/config:/config + # ports: + # - 8112:8112 + # restart: unless-stopped + #jackett: + # image: lscr.io/linuxserver/jackett:latest + # container_name: jackett + # environment: + # - PUID=1000 + # - PGID=1000 + # - TZ=Europe/London + # volumes: + # - ../tests/docker_configs/jackett/config:/config + # ports: + # - 9117:9117 + # restart: unless-stopped diff --git a/.devcontainer/example-env b/.devcontainer/example-env deleted file mode 100644 index 76f3da1..0000000 --- a/.devcontainer/example-env +++ /dev/null @@ -1,8 +0,0 @@ -RADARR_HOST= -RADARR_API_KEY= - -SONARR_HOST= -SONARR_API_KEY= - -READARR_HOST= -READARR_API_KEY= diff --git a/.devcontainer/recommended-devcontainer.json b/.devcontainer/recommended-devcontainer.json deleted file mode 100644 index 4abd5ca..0000000 --- a/.devcontainer/recommended-devcontainer.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "pyarr", - "dockerComposeFile": [ - "docker-compose.workspace.yml" - ], - "service": "pyarr-workspace", - "workspaceFolder": "/workspace", - "forwardPorts": [ - "sonarr:8989", - "radarr:7878", - "readarr:8787", - "lidarr:8686", - "jackett:9117", - "deluge:8112" - ], - "customizations": { - "vscode": { - "settings": { - "files.eol": "\n", - "editor.tabSize": 4, - "terminal.integrated.profiles.linux": { - "zsh": { - "path": "/bin/zsh" - } - }, - "terminal.integrated.defaultProfile.linux": "zsh", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true, - "python.formatting.provider": "black", - "autoDocstring.docstringFormat": "google" - }, - "extensions": [ - "github.vscode-pull-request-github", - "ms-python.python", - "ms-python.vscode-pylance", - "yzhang.markdown-all-in-one", - "tabnine.tabnine-vscode", - "rebornix.project-snippets", - "njpwerner.autodocstring", - "sourcery.sourcery" - ] - } - }, - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/git:1": {} - }, - "remoteUser": "vscode", - "postCreateCommand": "zsh ./.devcontainer/post-install.sh", - "mounts": [ - "source=${localEnv:HOME}/repos/pyarrfork,target=/workspace,type=bind,consistency=cached", - /* Re-use local SSH keys (useful if you use SSH keys for Git repo access or other SSH work)*/ - "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached", - /* Re-use local Git configuration*/ - "source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached", - /* map docker socket of host*/ - "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" - ] -} diff --git a/.github/release.yml b/.github/release.yml deleted file mode 100644 index 5bea7b5..0000000 --- a/.github/release.yml +++ /dev/null @@ -1,27 +0,0 @@ -# release.yml -changelog: - categories: - - title: ๐Ÿ’ฅ Breaking Changes - labels: - - semver/major - - flag/breaking changes - - title: ๐Ÿš€ Exciting New Features - labels: - - semver/minor - - type/feature - - title: ๐Ÿ› Patches & Bug Fixes - labels: - - semver/patch - - type/bug - - title: ๐Ÿ“š Documentation - labels: - - type/docs - - title: ๐Ÿ“” Language - labels: - - type/language - - title: โฌ†๏ธ Dependencies - labels: - - type/dependencies - - title: Other Changes - labels: - - "*" \ No newline at end of file diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml deleted file mode 100644 index 4f9569e..0000000 --- a/.github/workflows/check-version.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Check Version has been updated - -on: - pull_request: - branches: - - master - workflow_dispatch: -jobs: - checkVersion: - if: github.event_name == 'pull_request' - name: Check version updated - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v2 - - name: Check if Python files changed - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: | - .py - pyproject.toml - - name: Run step if any of the listed files above change - if: steps.changed-files.outputs.any_changed == 'true' - run: | - echo "One or more files has changed." - - name: Check package version - if: steps.changed-files.outputs.any_changed == 'true' - uses: dudo/tag_check@v1.1.1 - with: - git_tag_prefix: v diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 58133ef..f8aa499 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,10 +3,10 @@ name: coverage on: push: branches: - - master + - beta pull_request: branches: - - master + - beta workflow_dispatch: jobs: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..62f7950 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +name: Sphinx Documentation Build and Publish + +on: + push: + branches: + - main # Adjust branch name as needed + paths: + - "docs/**" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 # Adjust Python version as needed + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install poetry nox + pip install -r docs/requirements.txt + + - name: Build documentation + run: | + nox -s build_docs + + - name: Deploy to gh-pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./build/ diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml deleted file mode 100644 index 39c513c..0000000 --- a/.github/workflows/publish-docs.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -name: Sphinx Documentation Update - -on: - push: - tags: - - 'v*' - workflow_dispatch: - -jobs: - update-docs: - name: Update Documentation - runs-on: ubuntu-latest - steps: - - name: Getting your configuration from GitHub - uses: actions/checkout@v2 - - - name: Update documentation - uses: totaldebug/sphinx-publish-action@master - with: - sphinx_src: sphinx-docs - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e94858..c8caaea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,11 @@ -name: release +--- +name: Semantic Release on: push: - tags: - - 'v*' + branches: + - main + - beta workflow_dispatch: jobs: @@ -36,35 +38,46 @@ jobs: run: | pip install poetry nox nox -s tests - - build-n-publish: + release: name: Create release and publish ๐Ÿ distribution ๐Ÿ“ฆ to PyPI - if: startsWith(github.ref, 'refs/tags/') needs: [code-quality] runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + steps: - - name: Getting your configuration from GitHub - uses: actions/checkout@v2 - - name: ๐Ÿ›Ž๏ธ Create release - id: create_release - uses: softprops/action-gh-release@v1 - with: - generate_release_notes: true - prerelease: ${{ contains(needs.tag_version.outputs.tag, '-rc') || contains(needs.tag_version.outputs.tag, '-b') || contains(needs.tag_version.outputs.tag, '-a') }} - - name: ๐Ÿท๏ธ Update latest tag - uses: EndBug/latest-tag@latest + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - # PyPi release steps - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.11 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install poetry nox - - name: Publish distribution ๐Ÿ“ฆ to PyPI - run: | - nox -rs release -- "$PYPI_PASSWORD" - env: - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install poetry nox + npm install @semantic-release/changelog + npm install @semantic-release/exec + npm install @semantic-release/git + npm install @semantic-release/github + npm install conventional-changelog-conventionalcommits@7.0.2 + npm install semantic-release-pypi + + - name: Run Release + run: | + nox -rs release -- "$PYPI_PASSWORD" + env: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿท๏ธ Update latest tag + uses: EndBug/latest-tag@latest diff --git a/.github/workflows/release.yml.old b/.github/workflows/release.yml.old new file mode 100644 index 0000000..6e94858 --- /dev/null +++ b/.github/workflows/release.yml.old @@ -0,0 +1,70 @@ +name: release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + code-quality: + name: ๐Ÿ“Š Check code quality + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Run containers + run: docker-compose -f .ci/docker-compose.yml up -d + - name: Add hosts + run: | + sudo echo "127.0.0.1 sonarr readarr radarr lidarr prowlarr deluge jackett" | sudo tee -a /etc/hosts + - name: sleep 30s for containers to start-up + run: sleep 30s + shell: bash + - name: check ports are mapped + run: docker ps + - name: check one of the containers is up + run: curl http://radarr:7878 + - name: ๐Ÿงช Check tests are passing + run: | + pip install poetry nox + nox -s tests + + build-n-publish: + name: Create release and publish ๐Ÿ distribution ๐Ÿ“ฆ to PyPI + if: startsWith(github.ref, 'refs/tags/') + needs: [code-quality] + runs-on: ubuntu-latest + steps: + - name: Getting your configuration from GitHub + uses: actions/checkout@v2 + - name: ๐Ÿ›Ž๏ธ Create release + id: create_release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + prerelease: ${{ contains(needs.tag_version.outputs.tag, '-rc') || contains(needs.tag_version.outputs.tag, '-b') || contains(needs.tag_version.outputs.tag, '-a') }} + - name: ๐Ÿท๏ธ Update latest tag + uses: EndBug/latest-tag@latest + + # PyPi release steps + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install poetry nox + - name: Publish distribution ๐Ÿ“ฆ to PyPI + run: | + nox -rs release -- "$PYPI_PASSWORD" + env: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f17724e..09ac778 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,10 +3,11 @@ name: tests on: push: branches: - - master + - beta pull_request: branches: - - master + - main + - beta schedule: - cron: "0 0 * * *" workflow_dispatch: diff --git a/.gitignore b/.gitignore index 2277a73..afbd16f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,13 +25,6 @@ coverage.xml _build .nox -.devcontainer/* -!.devcontainer/recommended-devcontainer.json -!.devcontainer/Dockerfile -!.devcontainer/recommended-docker-compose.yml -!.devcontainer/docker-compose.workspace.yml -!.devcontainer/post-install.sh - tests/docker_configs/sonarr/* !tests/docker_configs/sonarr/config.xml tests/docker_configs/radarr/* diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..055e021 --- /dev/null +++ b/.releaserc @@ -0,0 +1,54 @@ +{ + "debug": true, + "branches": [ + "main" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + "@semantic-release/changelog", + [ + "semantic-release-pypi", + { + "pypiPublish": false + } + ], + [ + "@semantic-release/exec", + { + "prepareCmd": "poetry build" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md", + "pyproject.toml" + ], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ], + [ + "@semantic-release/github", + { + "assets": [ + { + "path": "dist/*" + } + ] + } + ], + "@semantic-release/changelog" + ] +} diff --git a/sphinx-docs/Makefile b/docs/Makefile similarity index 100% rename from sphinx-docs/Makefile rename to docs/Makefile diff --git a/sphinx-docs/conf.py b/docs/conf.py similarity index 100% rename from sphinx-docs/conf.py rename to docs/conf.py diff --git a/sphinx-docs/contributing.rst b/docs/contributing.rst similarity index 100% rename from sphinx-docs/contributing.rst rename to docs/contributing.rst diff --git a/sphinx-docs/index.rst b/docs/index.rst similarity index 100% rename from sphinx-docs/index.rst rename to docs/index.rst diff --git a/sphinx-docs/installing.rst b/docs/installing.rst similarity index 100% rename from sphinx-docs/installing.rst rename to docs/installing.rst diff --git a/sphinx-docs/make.bat b/docs/make.bat similarity index 95% rename from sphinx-docs/make.bat rename to docs/make.bat index 27f573b..7893348 100644 --- a/sphinx-docs/make.bat +++ b/docs/make.bat @@ -1,35 +1,35 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/sphinx-docs/models/common.rst b/docs/models/common.rst similarity index 100% rename from sphinx-docs/models/common.rst rename to docs/models/common.rst diff --git a/sphinx-docs/models/lidarr.rst b/docs/models/lidarr.rst similarity index 100% rename from sphinx-docs/models/lidarr.rst rename to docs/models/lidarr.rst diff --git a/sphinx-docs/models/radarr.rst b/docs/models/radarr.rst similarity index 100% rename from sphinx-docs/models/radarr.rst rename to docs/models/radarr.rst diff --git a/sphinx-docs/models/readarr.rst b/docs/models/readarr.rst similarity index 100% rename from sphinx-docs/models/readarr.rst rename to docs/models/readarr.rst diff --git a/sphinx-docs/models/sonarr.rst b/docs/models/sonarr.rst similarity index 100% rename from sphinx-docs/models/sonarr.rst rename to docs/models/sonarr.rst diff --git a/sphinx-docs/modules/lidarr.rst b/docs/modules/lidarr.rst similarity index 100% rename from sphinx-docs/modules/lidarr.rst rename to docs/modules/lidarr.rst diff --git a/sphinx-docs/modules/radarr.rst b/docs/modules/radarr.rst similarity index 100% rename from sphinx-docs/modules/radarr.rst rename to docs/modules/radarr.rst diff --git a/sphinx-docs/modules/readarr.rst b/docs/modules/readarr.rst similarity index 100% rename from sphinx-docs/modules/readarr.rst rename to docs/modules/readarr.rst diff --git a/sphinx-docs/modules/sonarr.rst b/docs/modules/sonarr.rst similarity index 100% rename from sphinx-docs/modules/sonarr.rst rename to docs/modules/sonarr.rst diff --git a/sphinx-docs/quickstart.rst b/docs/quickstart.rst similarity index 100% rename from sphinx-docs/quickstart.rst rename to docs/quickstart.rst diff --git a/sphinx-docs/requirements.txt b/docs/requirements.txt similarity index 100% rename from sphinx-docs/requirements.txt rename to docs/requirements.txt diff --git a/sphinx-docs/toc.rst b/docs/toc.rst similarity index 100% rename from sphinx-docs/toc.rst rename to docs/toc.rst diff --git a/noxfile.py b/noxfile.py index e0291e9..5c1801a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -147,16 +147,33 @@ def test_style(session: Session) -> None: @nox.session(reuse_venv=True) -def release(session: Session) -> None: - """Release a new version of the package""" - pypi_password = session.posargs[0] +def serve_docs(session: Session) -> None: + """Create local copy of docs for testing""" session.run("poetry", "install", external=True) - session.run("poetry", "build", external=True) - session.run("poetry", "publish", "-u", "__token__", "-p", pypi_password) + session.run("sphinx-autobuild", "docs", "build") @nox.session(reuse_venv=True) -def docs(session: Session) -> None: +def build_docs(session: Session) -> None: """Create local copy of docs for testing""" session.run("poetry", "install", external=True) - session.run("sphinx-build", "sphinx-docs", "build") + session.run("sphinx-build", "-b", "html", "docs", "build") + +@nox.session(reuse_venv=True) +def install_release(session: Session) -> None: + session.run("npm", "install", "@semantic-release/changelog") + session.run("npm", "install", "@semantic-release/exec") + session.run("npm", "install", "@semantic-release/git") + session.run("npm", "install", "@semantic-release/github") + session.run("npm", "install", "conventional-changelog-conventionalcommits@7.0.2") + session.run("npm", "install", "semantic-release-pypi") + +@nox.session(reuse_venv=True) +def release(session: Session) -> None: + """Release a new version of the package""" + pypi_password = session.posargs[0] + session.run("poetry", "install", external=True) + session.notify("install_release") + session.run("npx", "semantic-release", "--debug") + session.run("poetry", "build", external=True) + session.run("poetry", "publish", "-u", "__token__", "-p", pypi_password, external=True)