Skip to content

Commit

Permalink
Use PyPI trusted publishing to publish releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
kw committed Dec 6, 2024
1 parent c2d2b40 commit cf458f8
Showing 1 changed file with 59 additions and 10 deletions.
69 changes: 59 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
- 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/

0 comments on commit cf458f8

Please sign in to comment.