Reformat Docs and YAMLs (#12806)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-05-18 22:17:57 +02:00 committed by GitHub
parent d25dd182d6
commit e8e434fe48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 325 additions and 324 deletions

View file

@ -9,50 +9,50 @@ on:
# push:
# branches:
# - main
jobs:
Merge:
if: github.repository == 'ultralytics/ultralytics'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip" # caching pip dependencies
- name: Install requirements
run: |
pip install pygithub
- name: Merge main into PRs
shell: python
run: |
from github import Github
import os
# Authenticate with the GitHub Token
g = Github(os.getenv('GITHUB_TOKEN'))
# Get the repository dynamically
repo = g.get_repo(os.getenv('GITHUB_REPOSITORY'))
# List all open pull requests
open_pulls = repo.get_pulls(state='open', sort='created')
for pr in open_pulls:
try:
# Compare PR head with main to see if it's behind
comparison = repo.compare(pr.base.ref, pr.head.ref) # ensure correct order of base and head
if comparison.behind_by > 0:
# Merge main into the PR branch
success = pr.update_branch()
assert success, "Branch update failed"
print(f"Merged 'main' into PR #{pr.number} ({pr.head.ref}) successfully.")
except Exception as e:
print(f"Could not merge 'main' into PR #{pr.number} ({pr.head.ref}): {e}")
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip" # caching pip dependencies
- name: Install requirements
run: |
pip install pygithub
- name: Merge main into PRs
shell: python
run: |
from github import Github
import os
# Authenticate with the GitHub Token
g = Github(os.getenv('GITHUB_TOKEN'))
# Get the repository dynamically
repo = g.get_repo(os.getenv('GITHUB_REPOSITORY'))
# List all open pull requests
open_pulls = repo.get_pulls(state='open', sort='created')
for pr in open_pulls:
try:
# Compare PR head with main to see if it's behind
comparison = repo.compare(pr.base.ref, pr.head.ref) # ensure correct order of base and head
if comparison.behind_by > 0:
# Merge main into the PR branch
success = pr.update_branch()
assert success, "Branch update failed"
print(f"Merged 'main' into PR #{pr.number} ({pr.head.ref}) successfully.")
except Exception as e:
print(f"Could not merge 'main' into PR #{pr.number} ({pr.head.ref}): {e}")
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}

View file

@ -40,23 +40,23 @@ jobs:
import os
import ultralytics
from ultralytics.utils.checks import check_latest_pypi_version
v_local = tuple(map(int, ultralytics.__version__.split('.')))
v_pypi = tuple(map(int, check_latest_pypi_version().split('.')))
print(f'Local version is {v_local}')
print(f'PyPI version is {v_pypi}')
d = [a - b for a, b in zip(v_local, v_pypi)] # diff
increment_patch = (d[0] == d[1] == 0) and (0 < d[2] < 3) # publish if patch version increments by 1 or 2
increment_minor = (d[0] == 0) and (d[1] == 1) and v_local[2] == 0 # publish if minor version increments
increment = increment_patch or increment_minor
os.system(f'echo "increment={increment}" >> $GITHUB_OUTPUT')
os.system(f'echo "version={ultralytics.__version__}" >> $GITHUB_OUTPUT')
if increment:
print('Local version is higher than PyPI version. Publishing new version to PyPI ✅.')
id: check_pypi