Skip to content

Commit

Permalink
ci: use separate jobs for version & publishing
Browse files Browse the repository at this point in the history
to work around circular dep issue
  • Loading branch information
kelly-sovacool committed Oct 3, 2024
1 parent f5f46c6 commit 7ad7b42
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
45 changes: 34 additions & 11 deletions .github/workflows/docs-quartodoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,38 @@ on:
types: [published]

jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION_SHORT }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ccbr_actions@git+https://github.com/CCBR/actions
- name: set major & minor version
if: github.ref_type == 'tag' && startswith(github.ref, 'refs/tags/v')
id: version
shell: python {0}
run: |
from ccbr_actions.versions import get_major_minor_version
from ccbr_actions.actions import set_output
if '${{ github.ref_type }}' == 'tag' and '${{ github.ref }}'.startswith('refs/tags/v'):
version = 'dev'
else:
version = get_major_minor_version("${{ github.ref_name }}".lstrip("v"))
set_output('VERSION_SHORT', version)
docs:
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -53,34 +83,27 @@ jobs:
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
- name: set major & minor version
if: github.ref_type == 'tag' && startswith(github.ref, 'refs/tags/v')
id: version
shell: python {0}
run: from ccbr_actions.versions import get_major_minor_version
from ccbr_actions.actions import set_output
set_output('VERSION_SHORT', get_major_minor_version("${{ github.ref_name }}".lstrip("v")))
- name: publish dev docs
if: github.ref_name == 'main' && github.ref_type == 'branch'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
publish_branch: gh-pages
destination_dir: dev
destination_dir: ${{ needs.version.outputs.version }}
- name: publish stable docs
if: github.ref_type == 'tag' && startswith(github.ref, 'refs/tags/v')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
publish_branch: gh-pages
destination_dir: ${{ steps.version.outputs.VERSION_SHORT }}
destination_dir: ${{ needs.version.outputs.version }}
- name: create symlink stable to new version
if: github.ref_type == 'tag' && startswith(github.ref, 'refs/tags/v')
run: |
rm -if latest
ln -s ${{ steps.version.outputs.VERSION_SHORT }} latest
ln -s ${{ needs.version.outputs.version }} latest
ls -la
git add latest
git commit -m 'chore: link latest docs from ${{ github.ref_name }} (${{ steps.version.outputs.VERSION_SHORT }})' && git push || echo 'no changes to commit'
git commit -m 'chore: link latest docs from ${{ needs.version.outputs.version }} (tag ${{ github.ref_name }})' && git push || echo 'no changes to commit'
3 changes: 1 addition & 2 deletions src/ccbr_tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ test = [
"pytest-cov"
]
docs = [
"quartodoc >= v0.7.6",
"ccbr_actions@git+https://github.com/CCBR/actions"
"quartodoc >= v0.7.6"
]

[project.scripts]
Expand Down

0 comments on commit 7ad7b42

Please sign in to comment.