Skip to content

Commit

Permalink
Refactor Python publishing workflow
Browse files Browse the repository at this point in the history
- Updated the checkout action to version 3.5.3
- Set up Python 3.8 using actions/setup-python@v3.1.4
- Cached the installation of Poetry using actions/cache@v3.3.1
- Installed Poetry version 1.2.1 with snok/install-poetry@v1
- Used JRubics/poetry-publish@v1.17 to build and publish the Python package
  • Loading branch information
cblack34 committed Jul 13, 2023
1 parent e6f1f97 commit 229a5f7
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions .github/workflows/python-publish.yml
Expand Up @@ -7,22 +7,40 @@ on:
types: [created]

jobs:
deploy:

publish:
runs-on: ubuntu-latest

permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Build and publish
run: |
poetry build
poetry publish
- name: Checkout repository
uses: actions/checkout@v3.5.3

# If you wanted to use multiple Python versions, you'd have specify a matrix in the job and
# reference the matrixe python version here.
- name: Set up Python 3.8
uses: actions/setup-python@v3.1.4
with:
python-version: 3.8

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v3.3.1
with:
path: ~/.local
key: poetry-1.1.12-0

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: build and Publish python poetry package
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 229a5f7

Please sign in to comment.