diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1e133d6..3a5f552 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,7 +3,7 @@ * sofar version: * Python version: * Operating System: -* Did you install pyfar via pip: +* Did you install sofar via pip: ## Description diff --git a/.github/workflows/has_version_label.yml b/.github/workflows/has_label.yml similarity index 54% rename from .github/workflows/has_version_label.yml rename to .github/workflows/has_label.yml index 97e01ea..1750854 100644 --- a/.github/workflows/has_version_label.yml +++ b/.github/workflows/has_label.yml @@ -1,4 +1,4 @@ -name: PR Check Label for version Label +name: pull_request label on: pull_request: @@ -12,17 +12,15 @@ jobs: check-labels: runs-on: ubuntu-latest steps: - - name: Check for version label + - name: pull_request label run: | - echo "Checking for version label on pull request..." + echo "Checking for label on pull request..." PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}) LABEL_NAMES=$(echo "$PR_DATA" | jq -r '.labels[].name') echo "Labels: $LABEL_NAMES" - REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" - MATCHES=$(echo "$LABEL_NAMES" | grep -E "$REGEX") - if [ -z "$MATCHES" ]; then - echo "Error: No version label found on this pull request. Please add a label in the format vX.Y.Z." + if [ -z "$LABEL_NAMES" ]; then + echo "Error: No label found on this pull request. Please add a label." exit 1 fi env: diff --git a/.github/workflows/has_version_milestone.yml b/.github/workflows/has_version_milestone.yml new file mode 100644 index 0000000..1a2bf74 --- /dev/null +++ b/.github/workflows/has_version_milestone.yml @@ -0,0 +1,29 @@ +name: pull_request version milestone + +on: + pull_request: + types: + - opened + - labeled + - unlabeled + - synchronize + +jobs: + check-labels: + runs-on: ubuntu-latest + steps: + - name: pull_request version milestone + run: | + echo "Checking for version milestone on pull request..." + PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}) + MILESTONE_NAME=$(echo "$PR_DATA" | jq -r '.milestone.title') + echo "Milestone: $MILESTONE_NAME" + + REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" + MATCHES=$(echo "$MILESTONE_NAME" | grep -E "$REGEX") + if [ -z "$MATCHES" ]; then + echo "Error: No version milestone found on this pull request. Please add a milestone in the format vX.Y.Z." + exit 1 + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/conf.py b/docs/conf.py index 1f5c04f..749f567 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,7 @@ import sys import urllib3 import shutil +import numpy as np sys.path.insert(0, os.path.abspath('..')) import sofar @@ -117,7 +118,8 @@ "navbar_start": ["navbar-logo"], "navbar_end": ["navbar-icon-links", "theme-switcher"], "navbar_align": "content", - "header_links_before_dropdown": 8, + "header_links_before_dropdown": None, # will be automatically set later based on headers.rst + "header_dropdown_text": "Packages", # Change dropdown name from "More" to "Packages" "icon_links": [ { "name": "GitHub", @@ -152,16 +154,44 @@ '_static/header.rst', 'resources/logos/pyfar_logos_fixed_size_sofar.png', ] -c = urllib3.PoolManager() -for file in folders_in: - url = link + file - filename = file - os.makedirs(os.path.dirname(filename), exist_ok=True) - with c.request('GET', url, preload_content=False) as res, open(filename, 'wb') as out_file: - shutil.copyfileobj(res, out_file) + +def download_files_from_gallery(link, folders_in): + c = urllib3.PoolManager() + for file in folders_in: + url = link + file + filename = file + os.makedirs(os.path.dirname(filename), exist_ok=True) + with c.request('GET', url, preload_content=False) as res: + if res.status == 200: + with open(filename, 'wb') as out_file: + shutil.copyfileobj(res, out_file) + +download_files_from_gallery(link, folders_in) +# if logo does not exist, use pyfar logo +if not os.path.exists(html_logo): + download_files_from_gallery( + link, ['resources/logos/pyfar_logos_fixed_size_pyfar.png']) + shutil.copyfile( + 'resources/logos/pyfar_logos_fixed_size_pyfar.png', html_logo) # replace sofar hard link to internal link with open("_static/header.rst", "rt") as fin: with open("header.rst", "wt") as fout: - for line in fin: - fout.write(line.replace(f'https://{project}.readthedocs.io', project)) + lines = [line.replace(f'https://{project}.readthedocs.io', project) for line in fin] + contains_project = any(project in line for line in lines) + + fout.writelines(lines) + + # add project to the list of projects if not in header + if not contains_project: + fout.write(f' {project} <{project}>\n') + + # count the number of gallery headings + count_gallery_headings = np.sum( + ['https://pyfar-gallery.readthedocs.io' in line for line in lines]) + + +# set dropdown header after gallery headings +html_theme_options['header_links_before_dropdown'] = count_gallery_headings+1 + + diff --git a/pyproject.toml b/pyproject.toml index ae53b3b..1c8ae6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dependencies = [ 'netCDF4', @@ -122,6 +123,7 @@ lint.select = [ [tool.ruff.lint.pydocstyle] convention = "numpy" + [tool.bumpversion] current_version = "1.2.1" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)"