Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: allow auto releasing to pypi #154

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release
on:
release:
types: [published]

jobs:
release:
name: Upload release to PyPI
runs-on: ubuntu-latest
if: github.repository == 'pytest-dev/pytest-timeout'
flub marked this conversation as resolved.
Show resolved Hide resolved
flub marked this conversation as resolved.
Show resolved Hide resolved

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the publish action recommends building without this permission to minimise access to this permission. I guess that means adding a separate job for the building and passing the build output along as artefacts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @aqeelat wants to go with that route, see how pytest-mock does it: https://github.com/pytest-dev/pytest-mock/blob/fcde66b13d09cb5507fe7e4f35e171adaf22994d/.github/workflows/deploy.yml#L13-L25

(we also build the package using @hynek's excellent build-and-inspect-python-package action).


steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
flub marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build

- name: Build package
run: |
python -m build
python -m twine check dist/*

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 2 additions & 3 deletions .github/workflows/main.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: build
name: Test
"on": [push, pull_request]
jobs:
build:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = pytest-timeout
description = pytest plugin to abort hanging tests
long_description = file: README.rst
long_description_content_type = text/x-rst
version = 2.2.0
author = Floris Bruynooghe
author_email = flub@devork.be
Expand Down
Loading