Merge pull request #136 from neherlab/docs/update-readme #45
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
on: | |
push: | |
branches: [ 'master', 'release-pypangraph' ] | |
pull_request: | |
paths: | |
- packages/pypangraph/** | |
- .github/workflows/pypangraph.yml | |
repository_dispatch: | |
types: build | |
workflow_dispatch: | |
workflow_call: | |
concurrency: | |
group: pypangraph-${{ github.workflow }}-${{ github.ref_type }}-${{ github.event.pull_request.number || github.ref || github.run_id }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -euo pipefail {0} | |
env: | |
GITHUB_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }} | |
jobs: | |
build: | |
name: "Build PyPangraph (${{ matrix.python-version }})" | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
lfs: true | |
- name: "Set up Python ${{ matrix.python-version }}" | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: "Install dependencies" | |
run: | | |
cd packages/pypangraph | |
python -m pip install --upgrade pip | |
python -m pip install flake8 pytest | |
python -m pip install . | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: "Lint" | |
run: | | |
cd packages/pypangraph | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: "Test" | |
run: | | |
cd packages/pypangraph | |
pytest | |
publish-to-pypi: | |
name: "Publish to PyPI" | |
needs: [ build ] | |
if: endsWith(github.ref, '/release-pypangraph') | |
runs-on: ubuntu-24.04 | |
environment: | |
name: ${{ github.ref }} | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
lfs: true | |
- name: "Setup Python" | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: "Install dependencies" | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build twine | |
- name: "Build package" | |
run: | | |
cd packages/pypangraph | |
python -m build | |
- name: "Publish package" | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.NEHERLAB_BOT_PYPI_TOKEN }} | |
run: | | |
twine upload --non-interactive packages/pypangraph/dist/* | |
- name: "Create git tag" | |
run: | | |
mkdir -p ${HOME}/bin | |
export PATH="${PATH}:${HOME}/bin" | |
curl -fsSL "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_linux_amd64" -o "${HOME}/bin/dasel" && chmod +x "${HOME}/bin/dasel" | |
git config --global user.name "${{ secrets.NEHERLAB_BOT_GITHUB_NAME }}" | |
git config --global user.email "${{ secrets.NEHERLAB_BOT_GITHUB_EMAIL }}" | |
version=$(dasel select -r toml -w - -s ".package.version" -f "packages/pypangraph/pyproject.toml") | |
git tag "pypangraph-${version}" | |
git push origin "pypangraph-${version}" |