Skip to content

Commit

Permalink
Update decomon install in tutorials when publishing a release
Browse files Browse the repository at this point in the history
- By default, tutorials (in colab) install dev version of decomon
- When publishing a release, we modify the notebooks to install the
  release version, by replacing "git+https://github.com/airbus/decomon@main#egg=decomon"
- Then we push a new tag named "tutorials-vx.y.z" (if release is named
  "vx.y.z").
- In the release doc, the github and colab links for tutorials will point to this new tag,
  so that the proper version of decomon is used.
  • Loading branch information
nhuet committed Dec 5, 2022
1 parent 6ab49aa commit d13b264
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 7 deletions.
43 changes: 36 additions & 7 deletions .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ on:
required: false
default: "docs/build/html"
type: string
notebooks-repo-url:
description: |
Url of the repository containing the notebooks, used to generate github and colab links.
By default, the current repository url.
required: false
default: ""
type: string
notebooks-branch:
description: |
Branch containing the notebooks, used to generate github and colab links.
By default, the current branch.
required: false
default: ""
type: string
outputs:
doc-version:
description: "Version name of the generated doc. Correspond to the verrsion name used by Sphinx."
Expand All @@ -28,19 +42,34 @@ jobs:
steps:
- name: Set env variables for github links in doc
run: |
# notebooks source repo and branch depending if it is a commit push or a PR
# notebooks source repo and branch. First try to use workflow inputs
AUTODOC_NOTEBOOKS_REPO_URL=${{ inputs.notebooks-repo-url }}
AUTODOC_NOTEBOOKS_BRANCH=${{ inputs.notebooks-branch }}
# use github context if not defined in inputs
if [[ $GITHUB_REF == refs/pull* ]];
then
AUTODOC_NOTEBOOKS_REPO_URL="${GITHUB_SERVER_URL}/${{ github.event.pull_request.head.repo.full_name }}"
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_HEAD_REF}
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL="${GITHUB_SERVER_URL}/${{ github.event.pull_request.head.repo.full_name }}"
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_HEAD_REF}
fi
elif [[ $GITHUB_REF == refs/heads* ]];
then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/heads\//}
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/heads\//}
fi
elif [[ $GITHUB_REF == refs/tags* ]];
then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/tags\//}
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/tags\//}
fi
fi
# export in GITHUB_ENV for next steps
echo "AUTODOC_NOTEBOOKS_REPO_URL=${AUTODOC_NOTEBOOKS_REPO_URL}" >> $GITHUB_ENV
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.get_package_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -20,6 +22,13 @@ jobs:
- name: Build package
run: |
python -m build
- name: get package version and save it
id: get_package_version
run: |
wheelfile=$(ls ./dist/decomon*.whl)
version=$(python -c "print('$wheelfile'.split('-')[1])")
echo "version=$version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Upload as build artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -41,8 +50,38 @@ jobs:
with:
password: ${{ secrets.PYPI_API_TOKEN }}

update-tutorials-for-colab:
needs: [deploy]
runs-on: ubuntu-latest
outputs:
tuto-tag-name: ${{ steps.push-tuto-release-tag.outputs.new_tag_name }}
steps:
- uses: actions/checkout@v3
- name: replace decomon version to install in notebooks
run: |
version=${{ needs.deploy.outputs.package_version }}
old_pip_spec_pattern="\(pip.*install.*\)git+https.*egg=decomon"
new_pip_spec_pattern="\1decomon==$version"
sed -i -e "s|${old_pip_spec_pattern}|${new_pip_spec_pattern}|" tutorials/*.ipynb
- name: push it on a dedicated tag
id: push-tuto-release-tag
run: |
current_tag_name=${GITHUB_REF/refs\/tags\//} # stripping refs/tags/
new_tag_name="tutorials-${current_tag_name}"
echo ${new_tag_name}
git config user.name "Actions"
git config user.email "[email protected]"
git commit tutorials/*.ipynb -m "Install appropriate version of decomon"
git tag ${new_tag_name} -m "Release ${current_tag_name} + installation in tutorials updated"
git push origin ${new_tag_name}
# store new tag name
echo "new_tag_name=${new_tag_name}" >> $GITHUB_OUTPUT
build-doc:
uses: ./.github/workflows/build-doc.yml
with:
notebooks-branch: ${{ needs.update-tutorials-for-colab.outputs.tuto-tag-name }}
needs: ["update-tutorials-for-colab"]

deploy-doc:
needs: [build-doc, deploy]
Expand Down

0 comments on commit d13b264

Please sign in to comment.