Skip to content

📦 pyproject-fmt #2136

📦 pyproject-fmt

📦 pyproject-fmt #2136

name: 📦 pyproject-fmt
on:
workflow_dispatch:
inputs:
release:
description: "🚀 Release (semver bump)?"
required: true
default: "no"
type: choice
options: ["no", patch, minor, major]
push:
branches: ["main"]
paths:
- "toml-doc/**"
- "common/**"
- "toml-fmt-common/**"
- "tox-rules/**"
- "pyproject-fmt/**"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- ".github/workflows/pyproject_fmt_build.yaml"
- ".github/workflows/_build.yaml"
pull_request:
schedule:
- cron: "0 8 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}${{ github.event.inputs.release && github.event.inputs.release != 'no' && '-release' || '' }}
cancel-in-progress: ${{ github.event.inputs.release == 'no' || github.event.inputs.release == null }}
jobs:
changes:
name: 🔍 changes
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
run: ${{ github.event_name != 'pull_request' || steps.filter.outputs.run == 'true' }}
steps:
- name: 📥 Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: 🔍 Check for changes
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
run:
- 'toml-doc/**'
- 'common/**'
- 'toml-fmt-common/**'
- 'tox-rules/**'
- 'pyproject-fmt/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '.github/workflows/pyproject_fmt_build.yaml'
- '.github/workflows/_build.yaml'
build:
needs: changes
uses: ./.github/workflows/_build.yaml
with:
package-name: pyproject-fmt
pre-commit-mirror: tox-dev/pyproject-fmt
run: ${{ needs.changes.outputs.run }}
secrets: inherit # zizmor: ignore[secrets-inherit]
permissions:
contents: write
id-token: write
pull-requests: read
release:
name: 🚀 release
runs-on: ubuntu-24.04
environment:
name: release
url: https://pypi.org/project/pyproject-fmt/${{ needs.build.outputs.version }}
permissions:
id-token: write
contents: write
if: github.event.inputs.release != 'no' && github.event.inputs.release != null && github.ref == 'refs/heads/main'
needs: [build]
steps:
- name: 📥 Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.RELEASE_TOKEN }}
persist-credentials: true
- name: 📥 Download source
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: source
path: .
- name: 👀 Show changes
run: git diff HEAD -u
- name: 💾 Commit release
run: |
git config --global user.name 'Bernat Gabor'
git config --global user.email 'gaborbernat@users.noreply.github.com'
git commit -am "Release pyproject-fmt ${VERSION} [skip ci]"
env:
VERSION: ${{ needs.build.outputs.version }}
- name: 📥 Download wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: wheels-*
path: dist
merge-multiple: "true"
- name: 👀 Show wheels
run: ls -lth dist
- name: 🚀 Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
skip-existing: true
- name: 📢 Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
VERSION: ${{ needs.build.outputs.version }}
CHANGELOG: ${{ needs.build.outputs.changelog }}
run: |
git pull --rebase origin main
git tag "pyproject-fmt/${VERSION}"
git push
git push --tags
gh release create "pyproject-fmt/${VERSION}" \
--title="pyproject-fmt/${VERSION}" --verify-tag \
--notes "${CHANGELOG}"
- name: 🔄 Trigger pre-commit mirror sync
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: gh workflow run main.yaml --repo "tox-dev/pyproject-fmt"