Version updated from 0.9.3 to 0.10.0 #16
Workflow file for this run
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: Release | |
on: | |
push: | |
tags: ["*"] | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: The name of the tag to release | |
type: string | |
required: true | |
jobs: | |
# Package when a new tag is pushed | |
build-package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT }} | |
- name: Package | |
uses: hynek/build-and-inspect-python-package@v1 | |
# Create a GitHub release | |
release: | |
name: Create a GitHub release | |
runs-on: ubuntu-latest | |
needs: build-package | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Parse changelog | |
shell: bash | |
run: | | |
function extract_version_content() { | |
changelog=$1 | |
target_version=$2 | |
awk -v target="$target_version" ' | |
/^## / { | |
if (found) exit; | |
version=$2; | |
if (version == target) found=1; | |
next; | |
} | |
found { print; } | |
' <<< "$changelog" | |
} | |
changelog=$(cat "CHANGELOG.md") | |
target_version=${GITHUB_REF#refs/tags/} | |
echo "TAG_NAME=$target_version" >> $GITHUB_ENV | |
content=$(extract_version_content "$changelog" "$target_version") | |
if [ -n "$content" ]; then | |
echo "::notice::Found release notes for ${target_version}" | |
echo "$content" >> release-notes.md | |
else | |
echo "::warning::Did not find release notes for ${target_version}" | |
touch release-notes.md | |
fi | |
- name: Download packages built by build-and-inspect-python-package | |
uses: actions/download-artifact@v3 | |
with: | |
name: Packages | |
path: dist | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
tag_name: "${{ env.TAG_NAME }}" | |
body_path: release-notes.md | |
# Upload to real PyPI on GitHub Releases. | |
release-pypi: | |
name: Publish released package to pypi.org | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: build-package | |
steps: | |
- name: Download packages built by build-and-inspect-python-package | |
uses: actions/download-artifact@v3 | |
with: | |
name: Packages | |
path: dist | |
- name: Upload package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |