|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | unittests: |
10 | | - name: Run tests |
| 10 | + name: Run unittests |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 |
|
13 | 13 | strategy: |
|
23 | 23 | uses: ./.github/actions/unittests |
24 | 24 | with: |
25 | 25 | python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + prerelease: |
| 28 | + name: Pre-release (test-pypi) |
| 29 | + needs: unittests |
| 30 | + if: success() |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Build package |
| 35 | + run: python setup.py sdist bdist_wheel |
| 36 | + |
| 37 | + - name: Upload artifact |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: py-dependency-injection |
| 41 | + path: dist/ |
| 42 | + |
| 43 | + - name: Publish to Test PyPI |
| 44 | + uses: pypa/gh-action-pypi-publish@releases/v1.8 |
| 45 | + with: |
| 46 | + user: __token__ |
| 47 | + password: ${{ secrets.TEST_PYPI_TOKEN }} |
| 48 | + repository_url: https://test.pypi.org/legacy/ |
| 49 | + skip_existing: true |
| 50 | + |
| 51 | + release: |
| 52 | + name: Release (pypi) |
| 53 | + needs: prerelease |
| 54 | + if: success() |
| 55 | + if: github.event_name == 'workflow_run' && github.event.workflow_run.event == 'workflow_dispatch' |
| 56 | + runs-on: ubuntu-latest |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Download artifact |
| 60 | + uses: actions/download-artifact@v4 |
| 61 | + with: |
| 62 | + name: py-dependency-injection |
| 63 | + path: dist/ |
| 64 | + |
| 65 | + - name: Extract version from setup.py |
| 66 | + id: extract-version |
| 67 | + run: | |
| 68 | + version=$(grep -Eo "version=['\"]([^'\"]+)['\"]" setup.py | awk -F"'" '{print $2}') |
| 69 | + echo "Using version: $version" |
| 70 | + echo "::set-output name=RELEASE_VERSION::$version" |
| 71 | + |
| 72 | + - name: Publish to PyPI |
| 73 | + uses: pypa/gh-action-pypi-publish@releases/v1.8 |
| 74 | + with: |
| 75 | + user: __token__ |
| 76 | + password: ${{ secrets.PYPI_TOKEN }} |
| 77 | + repository_url: https://upload.pypi.org/legacy/ |
| 78 | + skip_existing: true |
| 79 | + |
| 80 | + - name: Set up Git |
| 81 | + run: | |
| 82 | + git config --global user.name "${{ github.actor }}" |
| 83 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 84 | + |
| 85 | + - name: Create and push tag |
| 86 | + run: | |
| 87 | + git tag -a v${{ steps.extract-version.outputs.RELEASE_VERSION }} -m "Release version v${{ steps.extract-version.outputs.RELEASE_VERSION }}" |
| 88 | + git push origin v${{ steps.extract-version.outputs.RELEASE_VERSION }} |
0 commit comments