Merge pull request #133 from gramaziokohler/dependabot/github_actions… #170
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: Build and publish package and docs | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v[0-9].[0-9]+.[0-9]+ | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Install and build | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout repo | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python 3.8 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
- | |
name: Install dependencies | |
env: | |
COMPAS_RRC_VER: v1.0.0 | |
RRC_USERNAME: ${{ secrets.rrc_username }} | |
RRC_PASSWORD: ${{ secrets.rrc_password }} | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install cython --install-option="--no-cython-compile" | |
python -m pip install wheel # https://stackoverflow.com/questions/34819221 | |
# Install first since, compas_rrc pulls compas_fab==0.12 | |
python -m pip install compas_fab==0.11.0 | |
mkdir ~/.ssh && ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts | |
pip install git+https://"$RRC_USERNAME":"$RRC_PASSWORD"@bitbucket.org/ethrfl/compas_rrc.git@"$COMPAS_RRC_VER"#egg=compas_rrc | |
- | |
name: Install | |
run: | | |
python -m pip install --no-cache-dir -e .[dev] | |
python -c "from setuptools_scm import get_version;get_version('.', write_to='src/rapid_clay_formations_fab/_version.py')" | |
- | |
name: Test | |
run: | | |
invoke test | |
- | |
name: Build docs | |
run: | | |
invoke docs | |
- | |
name: Upload docs for other jobs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: docs-dir | |
path: dist/docs/ | |
if-no-files-found: error | |
retention-days: 1 | |
- | |
name: Build package | |
run: | | |
python setup.py clean --all sdist bdist_wheel | |
- | |
name: Upload package artifacts for other jobs | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
with: | |
name: dist-files | |
path: | | |
dist/*.whl | |
dist/*.tar.gz | |
if-no-files-found: error | |
retention-days: 1 | |
publish_docs: | |
name: Publish docs | |
needs: build | |
if: github.event_name == 'push' && ! startsWith(github.ref, 'refs/tags') | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Download docs directory from build job | |
uses: actions/download-artifact@v2 | |
with: | |
name: docs-dir | |
path: docs | |
- | |
name: Publish docs on branch gh-pages | |
uses: crazy-max/ghaction-github-pages@v3.2.0 | |
with: | |
target_branch: gh-pages | |
build_dir: docs | |
jekyll: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_pkg: | |
name: Publish package on pypi and GitHub | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
steps: | |
- | |
name: Checkout code # This is needed for creating release on GitHub | |
uses: actions/checkout@v4 | |
- | |
name: Download dist directory from build job | |
uses: actions/download-artifact@v2 | |
with: | |
name: dist-files | |
path: dist | |
- | |
name: Upload and release package on PyPi | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
- | |
name: Create GitHub release and upload assets | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: | | |
dist/*.whl | |
dist/*.tar.gz |