|
1 | | -name: Upload Python Package |
| 1 | +name: Bump, Release, and Publish |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [created] |
| 4 | + workflow_dispatch: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + inputs: |
| 8 | + newversion: |
| 9 | + description: "Bump Type (major minor patch)" |
| 10 | + required: true |
| 11 | + default: "patch" |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - patch |
| 15 | + - minor |
| 16 | + - major |
| 17 | + testpublish: |
| 18 | + description: "Publish to TestPypi" |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: tag-and-release |
| 24 | + cancel-in-progress: true |
6 | 25 |
|
7 | 26 | jobs: |
8 | 27 | deploy: |
9 | 28 | runs-on: ubuntu-latest |
10 | 29 | steps: |
11 | | - - uses: actions/checkout@v2 |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + with: |
| 32 | + persist-credentials: false |
| 33 | + fetch-depth: 0 |
| 34 | + submodules: true |
12 | 35 | - name: Set up Python |
13 | | - uses: actions/setup-python@v2 |
| 36 | + uses: actions/setup-python@v4 |
| 37 | + - name: Install Poetry |
| 38 | + uses: snok/install-poetry@v1 |
14 | 39 | with: |
15 | | - python-version: "3.x" |
| 40 | + virtualenvs-create: true |
| 41 | + virtualenvs-in-project: true |
| 42 | + installer-parallel: true |
| 43 | + - name: Bump Version |
| 44 | + run: poetry version ${{ github.event.inputs.newversion }} |
| 45 | + - name: Get New Version |
| 46 | + id: get-new-version |
| 47 | + run: | |
| 48 | + echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT |
16 | 49 | - name: Install dependencies |
| 50 | + run: poetry install --with dev --no-interaction --no-root |
| 51 | + - name: Install project |
| 52 | + run: poetry install --with dev --no-interaction |
| 53 | + - name: Run tests |
| 54 | + run: | |
| 55 | + source .venv/bin/activate |
| 56 | + pytest tests/ |
| 57 | + - name: Poetry Build |
17 | 58 | run: | |
18 | | - python -m pip install --upgrade pip |
19 | | - pip install setuptools wheel twine build |
20 | | - - name: Build Dists |
| 59 | + poetry build |
| 60 | + - name: Poetry Publish to PyPi Test |
| 61 | + if: ${{ 'true' == github.event.inputs.testpublish }} |
21 | 62 | run: | |
22 | | - python -m build |
23 | | - - name: Publish to PyPI |
24 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 63 | + poetry config repositories.testpypi https://test.pypi.org/legacy/ |
| 64 | + poetry publish --repository testpypi --no-interaction --skip-existing |
| 65 | + env: |
| 66 | + POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 67 | + - name: Poetry Publish to PyPi |
| 68 | + run: | |
| 69 | + poetry publish --no-interaction |
| 70 | + env: |
| 71 | + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} |
| 72 | + - name: Commit & Push changes |
| 73 | + uses: actions-js/push@v1.3 |
| 74 | + with: |
| 75 | + author_email: david@davidlday.com |
| 76 | + author_name: ${{ github.actor }} |
| 77 | + message: |
| 78 | + "[skip ci] bumped to ${{ steps.get-new-version.outputs.version }}" |
| 79 | + github_token: ${{ secrets.VERSION_BUMP_TAG_TOKEN }} |
| 80 | + - name: Tag version |
| 81 | + id: tag-version |
| 82 | + uses: mathieudutour/github-tag-action@v6.1 |
| 83 | + with: |
| 84 | + custom_tag: ${{ steps.get-new-version.outputs.version }} |
| 85 | + create_annotated_tag: true |
| 86 | + github_token: ${{ secrets.VERSION_BUMP_TAG_TOKEN }} |
| 87 | + - name: Create a GitHub release |
| 88 | + uses: ncipollo/release-action@v1 |
25 | 89 | with: |
26 | | - user: __token__ |
27 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 90 | + tag: ${{ steps.tag-version.outputs.new_tag }} |
| 91 | + name: ${{ steps.tag-version.outputs.new_tag }} |
| 92 | + body: ${{ steps.tag-version.outputs.changelog }} |
0 commit comments