CI: Use latest actions and reusable workflows #51
This file contains 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: PyPI release | |
# yamllint disable-line rule:truthy | |
on: push | |
jobs: | |
publish: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Build package distribution files | |
run: >- | |
pipx run tox -e clean,build | |
- name: Configure TWINE | |
run: | | |
echo "TWINE_USERNAME=__token__" >> "$GITHUB_ENV" | |
echo "TWINE_PASSWORD=${{ secrets.PYPI_API_TOKEN }}" >> "$GITHUB_ENV" | |
- name: Publish to PyPI | |
run: >- | |
pipx run tox -e publish -- --repository pypi | |
- name: Get tag | |
id: tag | |
uses: devops-actions/[email protected] | |
- name: Convert tag | |
run: | | |
VER=$(echo "${{ steps.tag.outputs.tag }}" | tr . -) | |
echo "ANCHOR=${VER}" >> "$GITHUB_ENV" | |
- name: Generate reno report | |
run: | | |
# fetch last 30 changes | |
git fetch --depth=30 | |
pipx run tox -e reno -- report \ | |
--version "${{ steps.tag.outputs.tag }}" \ | |
2>/dev/null > reno-notes.md || true | |
if grep -q 'reno: FAIL' reno-notes.md | |
then | |
touch modified-reno-notes.md | |
else | |
sed '/^\.pkg.*$/d' reno-notes.md | | |
sed '/^reno:.*$/d' | | |
sed '/^\.\. .*$/d' | | |
sed '$d' | | |
sed '$d' | | |
sed '1d' > modified-reno-notes.md | |
fi | |
- name: Create Release Notes | |
run: | | |
gh release create ${{ steps.tag.outputs.tag }} --generate-notes \ | |
-F modified-reno-notes.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |