|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: {} |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Set up Python 3.13 |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: "3.13" |
| 26 | + |
| 27 | + - name: Install Poetry |
| 28 | + uses: snok/install-poetry@v1 |
| 29 | + with: |
| 30 | + version: latest |
| 31 | + virtualenvs-create: true |
| 32 | + virtualenvs-in-project: true |
| 33 | + installer-parallel: true |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: poetry install --extras dev --no-interaction |
| 37 | + |
| 38 | + - name: Run full CI pipeline |
| 39 | + run: poetry run poe ci |
| 40 | + |
| 41 | + release: |
| 42 | + needs: test |
| 43 | + runs-on: ubuntu-latest |
| 44 | + concurrency: release |
| 45 | + permissions: |
| 46 | + id-token: write |
| 47 | + contents: write |
| 48 | + outputs: |
| 49 | + released: ${{ steps.release.outputs.released }} |
| 50 | + version: ${{ steps.release.outputs.version }} |
| 51 | + tag: ${{ steps.release.outputs.tag }} |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + fetch-depth: 0 |
| 56 | + |
| 57 | + - name: Set up Python 3.13 |
| 58 | + uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.13" |
| 61 | + |
| 62 | + - name: Install Poetry |
| 63 | + uses: snok/install-poetry@v1 |
| 64 | + with: |
| 65 | + version: latest |
| 66 | + virtualenvs-create: true |
| 67 | + virtualenvs-in-project: true |
| 68 | + installer-parallel: true |
| 69 | + |
| 70 | + - name: Install dependencies |
| 71 | + run: poetry install --extras dev --no-interaction |
| 72 | + |
| 73 | + - name: Python Semantic Release |
| 74 | + id: release |
| 75 | + uses: python-semantic-release/python-semantic-release@v9.0.0 |
| 76 | + with: |
| 77 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + root_options: -vv |
| 79 | + |
| 80 | + - name: Build package |
| 81 | + if: steps.release.outputs.released == 'true' |
| 82 | + run: poetry build |
| 83 | + |
| 84 | + - name: Upload build artifacts |
| 85 | + if: steps.release.outputs.released == 'true' |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: dist |
| 89 | + path: dist/ |
| 90 | + |
| 91 | + publish-pypi: |
| 92 | + name: Publish to PyPI |
| 93 | + needs: release |
| 94 | + if: needs.release.outputs.released == 'true' |
| 95 | + runs-on: ubuntu-latest |
| 96 | + environment: |
| 97 | + name: PyPI Release |
| 98 | + url: https://pypi.org/p/stocktrim-openapi-client |
| 99 | + permissions: |
| 100 | + id-token: write |
| 101 | + steps: |
| 102 | + - name: Download build artifacts |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + name: dist |
| 106 | + path: dist/ |
| 107 | + |
| 108 | + - name: Publish to PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 110 | + with: |
| 111 | + attestations: true |
0 commit comments