v0.2.1 #5
Workflow file for this run
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
name: pypi | |
env: | |
MAIN_REPO_NAME: 'airbus/decomon' | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
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 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- 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: | |
name: dist | |
path: dist | |
- name: Publish package to TestPyPI (only for forks) | |
env: | |
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
if: github.repository != env.MAIN_REPO_NAME && env.TEST_PYPI_API_TOKEN != '' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ | |
- name: Publish package to PyPI (main repo) | |
env: | |
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
if: github.repository == env.MAIN_REPO_NAME && env.PYPI_API_TOKEN != '' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
update-tutorials-for-colab-and-binder: | |
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 colab notebooks | |
run: | | |
version=${{ needs.deploy.outputs.package_version }} | |
old_pip_spec_pattern="\(pip.*install.*\)git+https.*egg=decomon" | |
new_pip_spec_pattern="\1decomon==$version" | |
if ${{ github.repository != env.MAIN_REPO_NAME && secrets.TEST_PYPI_API_TOKEN != '' }} == 'true'; then | |
# install from TestPypi if on a fork | |
new_pip_spec_pattern="${new_pip_spec_pattern} --extra-index-url https://test.pypi.org/simple/" | |
fi | |
shopt -s globstar # enable ** | |
sed -i -e "s|${old_pip_spec_pattern}|${new_pip_spec_pattern}|" tutorials/**/*.ipynb | |
- name: replace decomon version to install in binder environment | |
run: | | |
version=${{ needs.deploy.outputs.package_version }} | |
linefilter="/^name/!" | |
old_pip_spec_pattern="\(\s*\)-.*decomon.*$" | |
new_pip_spec_pattern="\1- decomon==$version" | |
if ${{ github.repository != env.MAIN_REPO_NAME && secrets.TEST_PYPI_API_TOKEN != '' }} == 'true'; then | |
# install from TestPypi if on a fork | |
new_pip_spec_pattern="${new_pip_spec_pattern}\n\1- --extra-index-url https://test.pypi.org/simple/" | |
fi | |
sed_command="${linefilter}s|${old_pip_spec_pattern}|${new_pip_spec_pattern}|" | |
echo sed -i -e ${sed_command} binder/environment.yml | |
sed -i -e "${sed_command}" binder/environment.yml | |
- name: push modifications 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 binder/environment.yml tutorials -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-and-binder.outputs.tuto-tag-name }} | |
needs: ["update-tutorials-for-colab-and-binder"] | |
deploy-doc: | |
needs: [build-doc, deploy, update-tutorials-for-colab-and-binder] | |
uses: ./.github/workflows/deploy-doc.yml | |
with: | |
doc-version: ${{ needs.build-doc.outputs.doc-version }} | |
binder-env-fullref: ${{ github.repository }}/${{ needs.update-tutorials-for-colab-and-binder.outputs.tuto-tag-name }} |