diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d366e83d8..44c5eb94c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,33 +15,47 @@ on: # yamllint disable-line rule:truthy - '*.*' - 'staging*' +permissions: + contents: write + jobs: build: name: Build and Deploy runs-on: ubuntu-latest + env: + IS_DEPLOY: ${{ (github.event_name == 'push' && '1') || '0' }} + IS_STAGING: ${{ (github.ref == 'refs/heads/staging' && '1') || '0' }} + IS_MAIN: ${{ ((github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && '1') || '0' }} + steps: - name: Checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.11' - name: Install dependencies shell: bash run: ./ci/install.sh - name: List dependencies shell: bash - run: pip list + run: | + echo $IS_DEPLOY + echo $IS_PROD + echo $IS_MAIN + pip list - name: Build site shell: bash run: ./ci/build.sh + - name: Build site + shell: bash + run: make multidocs - name: Deploy to GitHub Pages - if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name != 'pull_request' + if: env.IS_DEPLOY uses: JamesIves/github-pages-deploy-action@v4 with: - FOLDER: ./doc/_build/html - CLEAN: true # Remove deleted files from the deploy branch + folder: ./doc/_build/html + clean: false # Don't remove files from other branches + dry-run: ${{ (env.IS_STAGING && 'true') || 'false' }} diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 6ff7d6445..882bbbb2c 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -32,9 +32,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.11' - name: Install dependencies shell: bash run: ./ci/install.sh diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 51174f70b..2f02753d2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -25,8 +25,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.11' - name: Run pre-commit hooks uses: pre-commit/action@v3.0.0 diff --git a/Makefile b/Makefile index 25bb41c04..9cd62a8a5 100644 --- a/Makefile +++ b/Makefile @@ -37,10 +37,9 @@ docs: ## generate Sphinx HTML documentation for the current branch $(MAKE) -C doc clean $(MAKE) -C doc html -multidocs: ## generate Sphinx HTML documentation for the multiple versions available - $(MAKE) -C doc clean - @python scripts/tagcurrent.py -v --exclude-pattern "^\d+\.\w|(master)$$" - sphinx-multiversion doc doc/_build/html +multidocs: ## prepare Sphinx HTML documentation for multiversion deployment + mkdir doc/_build/html/5 + mv doc/_build/html/* doc/_build/html/5 || true @python scripts/safecopy.py "5" "current" -v --base-path "doc/_build/html" @python scripts/generateredirects.py "current" -v --base-path "doc/_build/html" --base-url "https://docs.spyder-ide.org" diff --git a/doc/conf.py b/doc/conf.py index b9ada38c6..ee43fb64c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -147,7 +147,8 @@ "navigation_with_keys": False, "show_version_warning_banner": True, "switcher": { - "json_url": "https://docs.spyder-ide.org/versions.json", + "json_url": ( + "https://docs.spyder-ide.org/current/_static/versions.json"), "version_match": version, }, } diff --git a/scripts/tagcurrent.py b/scripts/tagcurrent.py deleted file mode 100755 index d19a0c483..000000000 --- a/scripts/tagcurrent.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python3 -"""Tag the current git branch with 'current' if not on a customizable list.""" - -# Standard library imports -import argparse -import os -import re -import subprocess - - -BRANCH_COMMAND = ["git", "branch", "--show-current", "--quiet"] -TAG_ADD_COMMAND = ["git", "tag", "-f", "-a", "current", "-m", - "Tag used for tracking the branch for Sphinx-Multiversion"] -TAG_DELETE_COMMAND = ["git", "tag", "-d", "current"] - -CI_BRANCH_VARIABLES = [ - "BRANCH", - "TRAVIS_PULL_REQUEST_BRANCH", - "TRAVIS_BRANCH", - ] - - -def tag_current_branch(exclude_pattern=None, verbose=False): - """Tag the current branch if it doesn't match an exclude pattern.""" - current_branch = subprocess.run( - BRANCH_COMMAND, check=False, stdout=subprocess.PIPE, encoding="utf-8") - branch_name = current_branch.stdout.strip() - - # Check CI variables if not on a branch (in a detached HEAD state) - if not branch_name and os.environ.get("CI", None): - for branch_variable in CI_BRANCH_VARIABLES: - branch_name = os.environ.get(branch_variable, "").strip() - if branch_name: - break - - if exclude_pattern and re.match(exclude_pattern, branch_name): - if verbose: - print(f"Current branch {branch_name!r} matches exclude pattern " - f"{exclude_pattern!r}, removing tag") - subprocess.run(TAG_DELETE_COMMAND, check=False) - return False - - if verbose: - print(f"Adding tag to current branch {branch_name!r}") - subprocess.run(TAG_ADD_COMMAND, check=False) - return True - - -def generate_arg_parser(): - """Create and return the argument parser for the tag current script.""" - arg_parser = argparse.ArgumentParser( - description="Tags a branch if it doesn't match an exclude pattern", - argument_default=argparse.SUPPRESS) - - arg_parser.add_argument( - "--exclude-pattern", help=( - "The regex pattern of the branch(es) to not tag." - "if not absolute; defaults to the working dir.")) - arg_parser.add_argument( - "-v", "--verbose", action="store_true", help=( - "If passed, prints whether the branch was tagged.")) - - return arg_parser - - -def main(argv=None): - """Tag the current branch if it doesn't match an exclude pattern.""" - arg_parser = generate_arg_parser() - parsed_args = arg_parser.parse_args(argv) - did_tag = tag_current_branch(**vars(parsed_args)) - return did_tag - - -if __name__ == "__main__": - main()