From 2745910989f85883115c1a21e9f1edfb6937e913 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 7 Aug 2024 12:29:03 -0400 Subject: [PATCH] ci: use reusable CCBR/actions workflow --- .github/workflows/docs-mkdocs.yml | 25 +++++++++ .github/workflows/docs.yml | 85 ------------------------------- README.md | 2 +- 3 files changed, 26 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/docs-mkdocs.yml delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs-mkdocs.yml b/.github/workflows/docs-mkdocs.yml new file mode 100644 index 0000000..4a926ef --- /dev/null +++ b/.github/workflows/docs-mkdocs.yml @@ -0,0 +1,25 @@ +name: docs +on: + workflow_dispatch: + release: + types: + - published + push: + branches: + - main + paths: + - "docs/**" + - "**.md" + - .github/workflows/docs-mkdocs.yml + - mkdocs.yml + +jobs: + mkdocs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: CCBR/actions/mkdocs-mike@main + with: + github-token: ${{ github.token }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 614374e..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: docs -on: - workflow_dispatch: - release: - types: - - published - push: - branches: - - main - paths: - - "docs/**" - - "**.md" - - .github/workflows/docs.yml - - mkdocs.yml - -env: - actor: "41898282+github-actions[bot]" - GH_TOKEN: ${{ github.token }} - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: 3.11 - cache: pip - - run: pip install --upgrade pip -r docs/requirements.txt - - name: git config - run: | - git config --local user.email "${actor}@users.noreply.github.com" - git config --local user.name "$actor" - gh release list > releases.tsv - - name: get version tag & alias - shell: python {0} - run: | - import os - import re - import warnings - - release_tag = '' - with open('releases.tsv', 'r') as infile: - for line in infile: - release_name, latest, tag, timestamp = line.strip().split('\t') - if latest == "Latest": - release_tag = tag.strip('v') - break - if not release_tag: - warnings.warn("No latest release found") - - with open('VERSION', 'r') as infile: - current_version = infile.read().strip() - - if current_version == release_tag: - docs_alias = 'latest' - # set version to just major and minor - semver_pattern = '(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' - release_semver = re.match(semver_pattern, release_tag) - docs_version = f"{release_semver.group('major')}.{release_semver.group('minor')}" - else: - semver_pattern = '(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' - release_semver = re.match(semver_pattern, release_tag) - current_semver = re.match(semver_pattern, current_version) - - groups = ['major', 'minor', 'patch'] - if current_semver.group('prerelease') and any([current_semver.group(grp) >= release_semver.group(grp) for grp in groups]): - docs_alias = '' - docs_version = 'dev' - else: - raise ValueError(f"current version {current_version} is not greater than latest release {release_tag}") - - - with open(os.getenv("GITHUB_ENV"), 'a') as out_env: - out_env.write(f"VERSION={docs_version}\n") - out_env.write(f"ALIAS={docs_alias}\n") - - - name: deploy docs - run: | - mike deploy ${{ env.VERSION }} ${{ env.ALIAS }} \ - --push \ - --update-aliases \ - --branch gh-pages diff --git a/README.md b/README.md index ae33a14..ff6d72c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # XAVIER - e**X**ome **A**nalysis and **V**ariant explor**ER** 🔬 [![tests](https://github.com/CCBR/XAVIER/workflows/tests/badge.svg)](https://github.com/CCBR/XAVIER/actions/workflows/main.yaml) -[![docs](https://github.com/CCBR/XAVIER/workflows/docs/badge.svg)](https://github.com/CCBR/XAVIER/actions/workflows/docs.yml) +[![docs](https://github.com/CCBR/XAVIER/workflows/docs/badge.svg)](https://github.com/CCBR/XAVIER/actions/workflows/docs-mkdocs.yml) [![Docker Pulls](https://img.shields.io/docker/pulls/nciccbr/ccbr_wes_base)](https://hub.docker.com/r/nciccbr/ccbr_wes_base) [![GitHub Issues](https://img.shields.io/github/issues/CCBR/XAVIER?color=brightgreen)](https://github.com/CCBR/XAVIER/issues) [![MIT license](https://img.shields.io/github/license/CCBR/XAVIER)](https://github.com/CCBR/XAVIER/blob/main/LICENSE)