Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add workflow for managing version listing #1836

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/doc-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Manage doc versions

on:
push:
branches:
- gh-pages
paths-ignore:
- 'dev/**'

jobs:
doc-versions:
name: Update Doc Versions
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Install packaging
run: python -m pip install packaging

- name: Update listing of versions
run: |
python << EOF
import json
from pathlib import Path
from packaging import version

# Get all paths that are versions
vers = sorted(version.parse(str(p)) for p in Path().glob('v[0-9]*'))

# Set up our version dictionary
versions = dict(versions=['latest', 'dev'],
latest=f'v{vers[-1].major}.{vers[-1].minor}', prereleases=[])
versions['versions'].extend(f'{v.major}.{v.minor}' for v in vers[-4:])

# Write to JSON file
with open('versions.json', 'wt') as verfile:
json.dump(versions, verfile)

# Update the 'latest' symlink
latest = Path('latest')
latest.unlink(missing_ok=True)
latest.symlink_to(versions['latest'], target_is_directory=True)
EOF

- name: Commit changes
run: |
git config user.name $GITHUB_ACTOR
git config user.email $GITHUB_ACTOR@users.noreply.github.com
git add latest versions.json
git commit -am "Update version listing and latest link" || true
git push