diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6861fbc..de83b4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,15 +4,22 @@ concurrency: cancel-in-progress: true on: push: + branches: + - master tags: - - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+' + pull_request: + branches: + - master + jobs: - release: - name: Release + build: + name: Build distribution 📦 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11' - uses: snok/install-poetry@v1 @@ -23,8 +30,50 @@ jobs: API_BASE_URL: ${{ vars.API_BASE_URL }} TASTYTRADE_LOGIN: ${{ secrets.TASTYTRADE_LOGIN }} TASTYTRADE_PASSWORD: ${{ secrets.TASTYTRADE_PASSWORD }} - - name: Publish - run: | - poetry publish --build \ - -u ${{ secrets.PYPI_USERNAME }} \ - -p ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file + - name: Build with Poetry + run: poetry build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/tastytrade-sdk + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/tastytrade-sdk + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/