Skip to content

Publish

Publish #5

Workflow file for this run

name: Publish
on:
push:
tags:
- v*
workflow_dispatch: # allows you to trigger manually
permissions:
contents: write
attestations: write
id-token: write
jobs:
release-notes:
name: Create Release Notes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Changelog
run: |-
echo "# Release Notes" > ${{ github.workflow }}-CHANGELOG.md
PAT="^## "
L1=$(grep -n "$PAT" CHANGELOG.md | sed -n '2p' | cut -d ":" -f 1)
L2=$(grep -n "$PAT" CHANGELOG.md | sed -n '3p' | cut -d ":" -f 1)
if [ -z "$L2" ]; then
tail -n +$L1 CHANGELOG.md >> ${{ github.workflow }}-CHANGELOG.md
else
awk "NR > $L1 && NR < $((L2 - 1))" CHANGELOG.md >> ${{ github.workflow }}-CHANGELOG.md
fi
- name: Remove extra spaces
run: |-
sed -i 's/- /- /g' ${{ github.workflow }}-CHANGELOG.md
- name: Github Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ github.workflow }}-CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-package:
name: Build and Inspect Python Package
runs-on: ubuntu-latest
needs: release-notes
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: true
release-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Generate artifact attestation for sdist and wheel
uses: actions/attest-build-provenance@v2
with:
subject-path: dist
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1