-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation deployment flow
- Loading branch information
Showing
5 changed files
with
96 additions
and
19 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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
--- | ||
name: Build & Deploy Docs | ||
name: Deploy Documentation | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.action_path }}-${{ github.ref }}-build-n-deploy-docs | ||
group: ${{ github.action_path }}-${{ github.ref }}-release-docs | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
run-build-n-deploy-docs: | ||
docs: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -27,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] | ||
|
@@ -35,16 +35,18 @@ jobs: | |
architecture: "x64" | ||
|
||
- name: Install Poetry | ||
run: pip install poetry==1.6.1 | ||
run: pip install poetry==1.8.4 | ||
|
||
- name: Install base dependencies | ||
run: poetry install --no-cache | ||
|
||
- name: Install dependencies | ||
run: poetry install --with=docs --no-cache --sync | ||
- 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: Run build & deploy documentation | ||
run: | | ||
poetry run mike deploy --push --update-aliases $(poetry version | awk '{ print $2 }') latest -F mkdocs.yaml | ||
- name: Deploy documentation | ||
run: poetry run python -m scripts.deploy_docs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 +1,7 @@ | ||
[tool.poetry] | ||
name = "pygerber" | ||
version = "2.4.2" | ||
description = "Parsing, formatting and rendering toolkit for Gerber X3 file format" | ||
description = "Parsing and rendering toolkit for Gerber X3 file format" | ||
authors = ["Krzysztof Wisniewski <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
@@ -104,7 +104,7 @@ mkdocs-macros-plugin = "^1.0.2" | |
mkdocs-gen-files = "^0.5.0" | ||
pygments = "^2.15.1" | ||
pymdown-extensions = "^10.3" | ||
mike = "^1.1.2" | ||
mike = "^2" | ||
black = "^24.4.0" | ||
|
||
[tool.poetry.extras] | ||
|
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,65 @@ | ||
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) | ||
@click.option("--check-only", is_flag=True, default=False) | ||
def main(*, is_dev: bool, check_only: 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 | ||
if check_only: | ||
return | ||
|
||
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() |
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,6 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
THIS_FILE = Path(__file__) | ||
THIS_DIRECTORY = THIS_FILE.parent |