|
| 1 | +name: Build & publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + workflow_call: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ["base-dind-2204-amd64"] |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + submodules: recursive |
| 18 | + |
| 19 | + - name: Find SHA |
| 20 | + run: | |
| 21 | + if [[ "${{github.event.pull_request.head.sha}}" != "" ]] |
| 22 | + then |
| 23 | + echo "ARTIFACT_SHA=$(echo ${{github.event.pull_request.head.sha}})" >> $GITHUB_ENV |
| 24 | + echo "CI_COMMIT_TAG=0.0.0" >> $GITHUB_ENV |
| 25 | + else |
| 26 | + echo "ARTIFACT_SHA=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV |
| 27 | + echo "CI_COMMIT_TAG=${{ github.ref_name }}" >> $GITHUB_ENV |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Install python dependencies |
| 31 | + run: | |
| 32 | + sudo apt update && sudo apt install -y python3.10-venv |
| 33 | + python3 -m venv .venv |
| 34 | + . .venv/bin/activate |
| 35 | + .venv/bin/python3 -m pip install --upgrade pip |
| 36 | + if [ -f requirements.txt ]; then .venv/bin/python3 -m pip install -r requirements.txt; fi |
| 37 | +
|
| 38 | + #- name: Lint with flake8 |
| 39 | + # run: | |
| 40 | + # # stop the build if there are Python syntax errors or undefined names |
| 41 | + # python3 -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 42 | + # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 43 | + # python3 -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 44 | + |
| 45 | + #- name: Test with pytest |
| 46 | + # env: |
| 47 | + # PYTHONPATH: . |
| 48 | + # run: | |
| 49 | + # python3 -m build |
| 50 | + # python3 -m pytest |
| 51 | + |
| 52 | + #- name: Test with coverage |
| 53 | + # env: |
| 54 | + # PYTHONPATH: . |
| 55 | + # run: | |
| 56 | + # python3 -m pytest tests/ |
| 57 | + |
| 58 | + - name: Build pip package |
| 59 | + run: | |
| 60 | + . .venv/bin/activate |
| 61 | + .venv/bin/python3 -m pip install build |
| 62 | + .venv/bin/python3 -m build |
| 63 | + VERSION=$(python3 setup.py --version) |
| 64 | + PYVER=$(python3 --version | awk '{print $2}' | awk -F\. '{print $1 $2 }') |
| 65 | +
|
| 66 | + # FIXME: add pypi publish step |
| 67 | + - name: Publish package |
| 68 | + #if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 69 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 70 | + with: |
| 71 | + password: ${{ secrets.PYPI_TOKEN }} |
0 commit comments