Skip to content

Commit c3156e9

Browse files
authored
Modernize test/deploy workflows (#179)
This aligns with the current best practices for package building, testing, and deploying via Trusted Publishers.
1 parent bf788f6 commit c3156e9

File tree

6 files changed

+127
-71
lines changed

6 files changed

+127
-71
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
groups:
6+
github-actions:
7+
patterns:
8+
- "*" # Group all Actions updates into a single larger pull request
9+
schedule:
10+
interval: weekly

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: deploy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
10+
11+
jobs:
12+
13+
package:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build and Check Package
20+
uses: hynek/[email protected]
21+
22+
deploy:
23+
needs: package
24+
runs-on: ubuntu-latest
25+
permissions:
26+
id-token: write # For PyPI trusted publishers.
27+
contents: write # For tag.
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Download Package
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: Packages
36+
path: dist
37+
38+
- name: Publish package to PyPI
39+
uses: pypa/[email protected]
40+
with:
41+
attestations: true
42+
43+
- name: GitHub Release
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
gh release create v${{ github.event.inputs.version }} --target=${{ github.ref_name }} --title v${{ github.event.inputs.version }}
48+
gh pr merge ${{ github.ref_name }} --merge

.github/workflows/main.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "test-me-*"
8+
9+
pull_request:
10+
branches:
11+
- "*"
12+
13+
env:
14+
FORCE_COLOR: 1
15+
16+
# Cancel running jobs for the same workflow and branch.
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
package:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Build and Check Package
27+
uses: hynek/[email protected]
28+
29+
test:
30+
needs: [package]
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
python-version: ["3.8", "3.9", "3.10", "3.11"]
36+
os: [ubuntu-latest, windows-latest]
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Download Package
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: Packages
45+
path: dist
46+
47+
- name: Set up Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Install tox
53+
run: |
54+
python -m pip install --upgrade pip
55+
python -m pip install --upgrade tox
56+
57+
- name: Test
58+
shell: bash
59+
run: |
60+
tox run -e py --installpkg `find dist/*.tar.gz`

HOWTORELEASE.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
Here are the steps on how to make a new release.
22

3-
#. Create a ``release-VERSION`` branch from ``upstream/master``.
3+
#. Create a ``release-VERSION`` branch from ``origin/master``.
44
#. Update ``CHANGELOG.rst``.
55
#. Push a branch with the changes.
66
#. Wait for all builds to pass and at least one approval.
7-
#. Push a tag ``VERSION`` to ``upstream``.
8-
#. Merge the PR.
7+
#. Start the ``deploy`` workflow:
8+
9+
.. code-block:: console
10+
11+
gh workflow run deploy.yml -R esss/pytest-regressions --ref release-VERSION --field version=VERSION
12+
13+
The PR will be automatically merged.
914

1015
After this, the package should be published directly to PyPI. After a few hours, it should be picked up by the conda-forge bot, where one of the maintainers need to merge it so the package can be published (another couple of hours after that).

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def read(fname: str) -> str:
2121
url="https://github.com/ESSS/pytest-regressions",
2222
description="Easy to use fixtures to write regression tests.",
2323
long_description=read("README.rst"),
24+
long_description_content_type="text/x-rst",
2425
packages=find_packages("src"),
2526
package_dir={"": "src"},
2627
python_requires=">=3.8",

0 commit comments

Comments
 (0)