|
| 1 | +name: Publish to PyPI [Test] |
| 2 | +on: [push] |
| 3 | +jobs: |
| 4 | + test-pypi: |
| 5 | + name: Create patch version number and push to test-pypi |
| 6 | + runs-on: ubuntu-latest |
| 7 | + steps: |
| 8 | + #---------------------------------------------- |
| 9 | + # check-out repo and set-up python |
| 10 | + #---------------------------------------------- |
| 11 | + - name: Check out repository |
| 12 | + uses: actions/checkout@v2 |
| 13 | + - name: Set up python |
| 14 | + id: setup-python |
| 15 | + uses: actions/setup-python@v2 |
| 16 | + with: |
| 17 | + python-version: 3.9 |
| 18 | + #---------------------------------------------- |
| 19 | + # ----- install & configure poetry ----- |
| 20 | + #---------------------------------------------- |
| 21 | + - name: Install Poetry |
| 22 | + uses: snok/install-poetry@v1 |
| 23 | + with: |
| 24 | + virtualenvs-create: true |
| 25 | + virtualenvs-in-project: true |
| 26 | + installer-parallel: true |
| 27 | + #---------------------------------------------- |
| 28 | + # load cached venv if cache exists |
| 29 | + #---------------------------------------------- |
| 30 | + - name: Load cached venv |
| 31 | + id: cached-poetry-dependencies |
| 32 | + uses: actions/cache@v2 |
| 33 | + with: |
| 34 | + path: .venv |
| 35 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }} |
| 36 | + #---------------------------------------------- |
| 37 | + # install dependencies if cache does not exist |
| 38 | + #---------------------------------------------- |
| 39 | + - name: Install dependencies |
| 40 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 41 | + run: poetry install --no-interaction --no-root |
| 42 | + #---------------------------------------------- |
| 43 | + # Get the current version and increment it (test-pypi requires a unique version number) |
| 44 | + #---------------------------------------------- |
| 45 | + - name: Get next version |
| 46 | + |
| 47 | + id: version |
| 48 | + with: |
| 49 | + scheme: semver |
| 50 | + increment: patch |
| 51 | + #---------------------------------------------- |
| 52 | + # Tell poetry to update the version number |
| 53 | + #---------------------------------------------- |
| 54 | + - name: Update pyproject.toml |
| 55 | + run: poetry version ${{ steps.version.outputs.major-version }}.${{ steps.version.outputs.minor-version }}.dev$(date +%s) |
| 56 | + #---------------------------------------------- |
| 57 | + # Attempt push to test-pypi |
| 58 | + #---------------------------------------------- |
| 59 | + - name: Build and publish to pypi |
| 60 | + |
| 61 | + with: |
| 62 | + pypi_token: ${{ secrets.TEST_PYPI_TOKEN }} |
| 63 | + repository_name: "testpypi" |
| 64 | + repository_url: "https://test.pypi.org/legacy/" |
0 commit comments