Skip to content

Commit

Permalink
Merge pull request #367 from pytest-dev/release-3.11.0
Browse files Browse the repository at this point in the history
Release 3.11.0
  • Loading branch information
nicoddemus committed Jun 16, 2023
2 parents 5818160 + b8ca8a6 commit f8b85bf
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 36 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ on:

jobs:

deploy:
package:
runs-on: ubuntu-latest
environment: deploy
permissions:
id-token: write # For PyPI trusted publishers.
contents: write # For tag and release notes.
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}

Expand All @@ -25,6 +21,17 @@ jobs:
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v1.5

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

steps:
- uses: actions/checkout@v3

- name: Download Package
uses: actions/download-artifact@v3
with:
Expand All @@ -36,7 +43,9 @@ jobs:

- name: Push tag
run: |
git tag v${{ github.event.inputs.version }} ${{ github.sha }}
git config user.name "pytest bot"
git config user.email "pytestbot@gmail.com"
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
git push origin v${{ github.event.inputs.version }}
- name: Set up Python
Expand All @@ -54,3 +63,5 @@ jobs:
uses: softprops/action-gh-release@v1
with:
body_path: scripts/latest-release-notes.md
files: dist/*
tag_name: v${{ github.event.inputs.version }}
37 changes: 28 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
name: test

on: [push, pull_request]
on:
push:
branches:
- main
- "test-me-*"

pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v1.5

test:

needs: [package]

runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -31,21 +47,24 @@ jobs:

steps:
- uses: actions/checkout@v3

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

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

- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test
shell: bash
run: |
tox -e ${{ matrix.tox_env }}
check-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v1.5
tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Releases
========

UNRELEASED
----------
3.11.1 (2023-06-15)
-------------------

* Fixed introspection for failed ``assert_has_calls`` (`#365`_).

Expand Down
49 changes: 30 additions & 19 deletions scripts/gen-release-notes.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
"""
Generates the release notes for the latest release, in Markdown.
Convert CHANGELOG.rst to Markdown, and extracts just the latest release.
Writes to ``scripts/latest-release-notes.md``, which can be
used with https://github.com/softprops/action-gh-release.
1. Extracts the latest release from the CHANGELOG.rst file.
2. Converts it to Markdown using pypandoc.
3. Writes to ``scripts/latest-release-notes.md``, which can be
used with https://github.com/softprops/action-gh-release.
"""
from pathlib import Path

import pypandoc

this_dir = Path(__file__).parent
rst_text = (this_dir.parent / "CHANGELOG.rst").read_text(encoding="UTF-8")
md_text = pypandoc.convert_text(
rst_text, "md", format="rst", extra_args=["--wrap=preserve"]
)

output_lines = []
first_heading_found = False
for line in md_text.splitlines():
if line.startswith("# "):
# Skip the first section (normally # Releases).
pass
elif line.startswith("## "):
# First second-level section, note it and skip the text,
# as we are only interested in the individual release items.
if first_heading_found:
capture = False
for line in rst_text.splitlines():
# Only start capturing after the latest release section.
if line.startswith("-------"):
capture = not capture
if not capture:
# We only need to capture the latest release, so stop.
break
first_heading_found = True
else:
continue

if capture:
output_lines.append(line)

# Drop last line, as it contains the previous release section title.
del output_lines[-1]

trimmed_rst = "\n".join(output_lines).strip()
print(">>Trimmed RST follows:")
print(trimmed_rst)
print(">>Trimmed RST ends")

md_text = pypandoc.convert_text(
trimmed_rst, "md", format="rst", extra_args=["--wrap=preserve"]
)
print(">>Converted Markdown follows:")
print(md_text)
print(">>Converted Markdown ends")

output_fn = this_dir / "latest-release-notes.md"
output_fn.write_text("\n".join(output_lines), encoding="UTF-8")
output_fn.write_text(md_text, encoding="UTF-8")
print(output_fn, "generated.")

0 comments on commit f8b85bf

Please sign in to comment.