-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how documentation deployments work
- Loading branch information
Showing
4 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
name: Deploy Development Documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.action_path }}-${{ github.ref }}-dev-docs | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
docs: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.8"] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: "x64" | ||
|
||
- name: Install Poetry | ||
run: pip install poetry==1.8.4 | ||
|
||
- name: Install base dependencies | ||
run: poetry install --no-cache | ||
|
||
- name: Prepare environment for docs deploy | ||
run: poetry run poe prepare-deploy-docs | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Deploy documentation | ||
run: poetry run python -m scripts.deploy_docs --is-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
name: Deploy Latest Documentation | ||
name: Deploy Documentation | ||
|
||
on: | ||
push: | ||
|
@@ -8,7 +8,7 @@ on: | |
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.action_path }}-${{ github.ref }}-latest-docs | ||
group: ${{ github.action_path }}-${{ github.ref }}-release-docs | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
|
@@ -26,6 +26,7 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/[email protected] | ||
|
@@ -48,4 +49,4 @@ jobs: | |
git config user.email [email protected] | ||
- name: Deploy documentation | ||
run: poetry run poe run deploy-latest-docs | ||
run: poetry run python -m scripts.deploy_docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import click | ||
import dulwich | ||
import dulwich.porcelain | ||
import dulwich.repo | ||
from mike.driver import main as mike_main | ||
from packaging.version import Version | ||
from test import THIS_DIRECTORY | ||
|
||
import pygerber | ||
|
||
|
||
@click.command() | ||
@click.option("--is-dev", is_flag=True, default=False) | ||
def main(*, is_dev: bool) -> None: | ||
version = Version(pygerber.__version__) | ||
|
||
is_unstable = version.is_devrelease or version.is_prerelease | ||
aliases = [] | ||
|
||
repo = dulwich.repo.Repo((THIS_DIRECTORY / ".." / ".git").as_posix()) | ||
versions = [Version(t.decode("utf-8")) for t in dulwich.porcelain.tag_list(repo)] | ||
|
||
if not is_dev: | ||
aliases.append(pygerber.__version__) | ||
|
||
latest_unstable = find_latest_unstable(versions) | ||
|
||
if version > latest_unstable: | ||
aliases.append("latest") | ||
|
||
latest_stable = find_latest_stable(versions) | ||
|
||
if not is_unstable and version > latest_stable: | ||
aliases.append("stable") | ||
|
||
else: | ||
aliases.append("dev") | ||
|
||
print("Aliases:", aliases) # noqa: T201 | ||
|
||
sys_argv_original = sys.argv.copy() | ||
|
||
sys.argv = ["mike", "deploy", "--push", "--update-aliases", *aliases] | ||
mike_main() | ||
|
||
sys.argv = sys_argv_original | ||
|
||
|
||
def find_latest_stable(versions: list[Version]) -> Version: | ||
return max(filter(lambda v: not (v.is_devrelease or v.is_prerelease), versions)) | ||
|
||
|
||
def find_latest_unstable(versions: list[Version]) -> Version: | ||
return max(filter(lambda v: (v.is_devrelease or v.is_prerelease), versions)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |