|
| 1 | +# This workflow will upload a Python Package using Twine when a release is created |
| 2 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 3 | + |
| 4 | +# This workflow uses actions that are not certified by GitHub. |
| 5 | +# They are provided by a third-party and are governed by |
| 6 | +# separate terms of service, privacy policy, and support |
| 7 | +# documentation. |
| 8 | + |
| 9 | +name: Upload Python Package |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - 'v*' |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: '3.x' |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install build |
| 28 | + - name: Build package |
| 29 | + run: python -m build |
| 30 | + - if: ${{failure()}} |
| 31 | + name: Create Issues |
| 32 | + uses: nashmaniac/create-issue-action@v1.1 |
| 33 | + with: |
| 34 | + title: Build Failed for uploading package |
| 35 | + token: ${{secrets.GITHUB_TOKEN}} |
| 36 | + assignees: ${{github.actor}} |
| 37 | + labels: worflow-failed |
| 38 | + body: Workflow failed for commit ${{github.sha}} @ ${{github.ref}} |
| 39 | + deploy_to_pypi: |
| 40 | + needs: build |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - name: Set up Python |
| 45 | + uses: actions/setup-python@v2 |
| 46 | + with: |
| 47 | + python-version: '3.10' |
| 48 | + - name: Install dependencies |
| 49 | + run: | |
| 50 | + python -m pip install --upgrade pip |
| 51 | + pip install setuptools wheel twine tomli |
| 52 | + pip install -r requirements.txt --upgrade |
| 53 | + pip install build |
| 54 | + python -m pip install --upgrade build |
| 55 | + - name: Publish a project to PyPi |
| 56 | + run: | |
| 57 | + python -m build |
| 58 | + twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN}} |
| 59 | + release: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: deploy_to_pypi |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + steps: |
| 65 | + - name: Checkout code |
| 66 | + uses: actions/checkout@v2 |
| 67 | + with: |
| 68 | + fetch-depth: 0 |
| 69 | + - name: Set environment variables for version number |
| 70 | + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 71 | + - name: Changelog |
| 72 | + uses: Bullrich/generate-release-changelog@master |
| 73 | + id: Changelog |
| 74 | + env: |
| 75 | + REPO: ${{ github.repository }} |
| 76 | + - name: ✏️ Generate release changelog |
| 77 | + uses: heinrichreimer/github-changelog-generator-action@v2.3 |
| 78 | + with: |
| 79 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + output: /CHANGELOG.md |
| 81 | + - name: Create Release |
| 82 | + id: create_release |
| 83 | + uses: actions/create-release@latest |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + tag_name: ${{ env.RELEASE_VERSION }} |
| 88 | + release_name: Release ${{ env.RELEASE_VERSION }} |
| 89 | + body: | |
| 90 | + ${{ steps.Changelog.outputs.changelog }} |
| 91 | + draft: false |
| 92 | + prerelease: false |
| 93 | + |
0 commit comments