|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish-pypi: |
| 11 | + name: Publish to PyPI |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Check out the repository |
| 15 | + |
| 16 | + with: |
| 17 | + fetch-depth: 2 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + |
| 21 | + with: |
| 22 | + python-version: "3.8" |
| 23 | + |
| 24 | + - name: Upgrade pip |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip --version |
| 28 | +
|
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + pip install wheel |
| 32 | + pip install tox tox-gh-actions |
| 33 | +
|
| 34 | + - name: Test with tox |
| 35 | + run: tox |
| 36 | + |
| 37 | + - name: Check passthrough models |
| 38 | + run: python scripts/generate_passthrough_modules.py check |
| 39 | + |
| 40 | + - name: Check if there is a parent commit |
| 41 | + id: check-parent-commit |
| 42 | + run: | |
| 43 | + echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)" |
| 44 | +
|
| 45 | + - name: Detect new version |
| 46 | + id: check-version |
| 47 | + if: steps.check-parent-commit.outputs.sha |
| 48 | + |
| 49 | + with: |
| 50 | + create-tag: false |
| 51 | + version-command: | |
| 52 | + bash -o pipefail -c "cat bioimageio/core/VERSION | jq -r '.version'" |
| 53 | +
|
| 54 | + - name: Push tag |
| 55 | + id: tag-version |
| 56 | + if: steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version |
| 57 | + uses: mathieudutour/[email protected] |
| 58 | + with: |
| 59 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + custom_tag: ${{ steps.check-version.outputs.current-version }} |
| 61 | + |
| 62 | + - name: Build package |
| 63 | + run: | |
| 64 | + python setup.py sdist bdist_wheel |
| 65 | +
|
| 66 | + - name: Publish package on PyPI |
| 67 | + if: steps.tag-version.outputs.new_tag |
| 68 | + |
| 69 | + with: |
| 70 | + user: __token__ |
| 71 | + password: "${{ secrets.PYPI_TOKEN }}" |
| 72 | + packages_dir: dist/ |
| 73 | + |
| 74 | + - name: Publish the release notes |
| 75 | + uses: release-drafter/[email protected] |
| 76 | + with: |
| 77 | + publish: "${{ steps.tag-version.outputs.new_tag != '' }}" |
| 78 | + tag: "${{ steps.tag-version.outputs.new_tag }}" |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
0 commit comments