Skip to content

Commit

Permalink
Modernize test/deploy workflows
Browse files Browse the repository at this point in the history
This aligns with the current best practices for package building, testing, and deploying via Trusted Publishers.
  • Loading branch information
nicoddemus committed Dec 17, 2024
1 parent e36302e commit cdc8061
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 71 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: weekly
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: deploy

on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
default: '1.2.3'

jobs:

package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build and Check Package
uses: hynek/[email protected]

deploy:
needs: package
runs-on: ubuntu-latest
permissions:
id-token: write # For PyPI trusted publishers.
contents: write # For tag.

steps:
- uses: actions/checkout@v4

- name: Download Package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Publish package to PyPI
uses: pypa/[email protected]
with:
attestations: true

- name: GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ github.event.inputs.version }} --target=${{ github.ref_name }} --title v${{ github.event.inputs.version }}
gh pr merge ${{ github.ref_name }} --merge
68 changes: 0 additions & 68 deletions .github/workflows/main.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test

on:
push:
branches:
- main
- "test-me-*"

pull_request:
branches:
- "*"

env:
FORCE_COLOR: 1

# Cancel running jobs for the same workflow and branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and Check Package
uses: hynek/[email protected]

test:
needs: [package]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v4

- name: Download Package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Test
shell: bash
run: |
tox run -e py --installpkg `find dist/*.tar.gz`
11 changes: 8 additions & 3 deletions HOWTORELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Here are the steps on how to make a new release.

#. Create a ``release-VERSION`` branch from ``upstream/master``.
#. Create a ``release-VERSION`` branch from ``origin/master``.
#. Update ``CHANGELOG.rst``.
#. Push a branch with the changes.
#. Wait for all builds to pass and at least one approval.
#. Push a tag ``VERSION`` to ``upstream``.
#. Merge the PR.
#. Start the ``deploy`` workflow:

.. code-block:: console
gh workflow run deploy.yml -R esss/pytest-regressions --ref release-VERSION --field version=VERSION
The PR will be automatically merged.

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).
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def read(fname: str) -> str:
url="https://github.com/ESSS/pytest-regressions",
description="Easy to use fixtures to write regression tests.",
long_description=read("README.rst"),
long_description_content_type="text/x-rst",
packages=find_packages("src"),
package_dir={"": "src"},
python_requires=">=3.8",
Expand Down

0 comments on commit cdc8061

Please sign in to comment.