Test and Release Template #24
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create GitHub Release | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
permissions: | |
contents: write | |
pull-requests: read | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: "3.13" | |
- name: Create Bogus Git Configuration | |
env: | |
GITHUB_NAME: "NOBODY" | |
GITHUB_EMAIL: "[email protected]" | |
run: | | |
git config --global user.name "$GITHUB_NAME" | |
git config --global user.email "$GITHUB_EMAIL" | |
- name: Run Fast Test Suite | |
run: | | |
uv run pytest -m 'not slow and not integration and not cross_platform' --ignore=tests/test_configuration_matrix.py --ignore=tests/test_generate_projects.py tests/ | |
release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: "3.13" | |
- name: Generate release notes | |
id: release_notes | |
run: | | |
# Get the tag name | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
# Get the previous tag | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${TAG_NAME}^ 2>/dev/null || echo "") | |
# Generate changelog | |
if [[ -n "$PREVIOUS_TAG" ]]; then | |
echo "## Changes since $PREVIOUS_TAG" >> release_notes.md | |
echo "" >> release_notes.md | |
git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..${TAG_NAME} >> release_notes.md | |
else | |
echo "## Initial Release" >> release_notes.md | |
echo "" >> release_notes.md | |
echo "- Initial release of python-package-cookiecutter" >> release_notes.md | |
fi | |
# Check if there's a CHANGELOG.md file | |
if [[ -f "CHANGELOG.md" ]]; then | |
echo "" >> release_notes.md | |
echo "## Full Changelog" >> release_notes.md | |
echo "" >> release_notes.md | |
echo "See [CHANGELOG.md](CHANGELOG.md) for complete release notes." >> release_notes.md | |
fi | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
bodyFile: "release_notes.md" | |
draft: false | |
prerelease: false | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} |