|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger the workflow on push or pull request to main |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - name: Set up Python 3.8 |
| 15 | + uses: actions/setup-python@v1 |
| 16 | + with: |
| 17 | + python-version: 3.8 |
| 18 | + - name: Install dependencies |
| 19 | + run: | |
| 20 | + pip install poetry |
| 21 | + poetry install |
| 22 | + - name: Test with pytest |
| 23 | + run: poetry run pytest --cov=./ --cov-report=xml |
| 24 | + - name: Upload coverage to Codecov |
| 25 | + uses: codecov/codecov-action@v1 |
| 26 | + with: |
| 27 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 28 | + file: ./coverage.xml |
| 29 | + flags: unittests |
| 30 | + name: codecov-umbrella |
| 31 | + fail_ci_if_error: true |
| 32 | + - name: checkout |
| 33 | + uses: actions/checkout@master |
| 34 | + with: |
| 35 | + ref: main |
| 36 | + - name: Bump version and tagging and publish |
| 37 | + run: | |
| 38 | + git config --local user.email "action@github.com" |
| 39 | + git config --local user.name "GitHub Action" |
| 40 | + git pull origin main |
| 41 | + poetry run semantic-release version |
| 42 | + poetry version $(grep "version" */__init__.py | cut -d "'" -f 2 | cut -d '"' -f 2) |
| 43 | + git commit -m "Bump versions" -a |
| 44 | + - name: Push package version changes |
| 45 | + uses: ad-m/github-push-action@master |
| 46 | + with: |
| 47 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + - name: Get release tag version from package version |
| 49 | + run: | |
| 50 | + echo ::set-output name=release_tag::$(grep "version" */__init__.py | cut -d "'" -f 2 | cut -d '"' -f 2) |
| 51 | + id: release |
| 52 | + - name: Create Release with new version |
| 53 | + id: create_release |
| 54 | + uses: actions/create-release@v1 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + with: |
| 58 | + tag_name: ${{ steps.release.outputs.release_tag }} |
| 59 | + release_name: ${{ steps.release.outputs.release_tag }} |
| 60 | + draft: false |
| 61 | + prerelease: false |
| 62 | + - name: Build package and publish to test PyPI |
| 63 | + env: |
| 64 | + TEST_PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} |
| 65 | + TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} |
| 66 | + run: | |
| 67 | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ |
| 68 | + poetry build |
| 69 | + poetry publish -r test-pypi -u $TEST_PYPI_USERNAME -p $TEST_PYPI_PASSWORD |
| 70 | +
|
0 commit comments