bump: version 3.0.1 → 3.1.0 #14
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: Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| # Match every PEP 440-flavored release tag, including pre/dev/post | |
| # variants like v2.1.0a0 / v2.1.0rc1 / v2.1.0.dev5 / v2.1.0.post1. | |
| # The plain `v*.*.*` glob would skip 4-segment forms (devN / postN). | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Build release distributions | |
| run: | | |
| python -m pip install build | |
| python -m build | |
| - name: Upload dists | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: release-build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Classify release (stable vs prerelease) | |
| id: prerelease | |
| # Tag without PEP 440 pre / dev suffix (plain `vMAJOR.MINOR.PATCH`) → | |
| # stable; anything else (aN / bN / rcN / .devN / .postN ...) → mark | |
| # the GitHub Release as a prerelease so it doesn't grab the | |
| # "Latest" badge from a stable on the repo's Releases page. | |
| # Note: .postN is technically a post-stable cleanup release per | |
| # PEP 440, but it's so rarely useful that treating it as | |
| # prerelease here is a fine simplification. | |
| run: | | |
| if [[ "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "is_prerelease=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "is_prerelease=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Extract latest changelog | |
| id: changelog | |
| run: | | |
| if [ -f CHANGELOG.md ]; then | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| CHANGELOG=$(awk -v version="$VERSION" ' | |
| BEGIN { found=0; content="" } | |
| /^## / { | |
| if (found) exit | |
| if ($0 ~ version) { | |
| found=1 | |
| content = content $0 "\n" | |
| next | |
| } | |
| next | |
| } | |
| found && /^## / { exit } | |
| found { content = content $0 "\n" } | |
| END { print content } | |
| ' CHANGELOG.md) | |
| echo "$CHANGELOG" > /tmp/changelog.txt | |
| else | |
| echo "Version ${{ steps.get_version.outputs.version }}" > /tmp/changelog.txt | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| body_path: /tmp/changelog.txt | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.whl | |
| draft: false | |
| prerelease: ${{ steps.prerelease.outputs.is_prerelease }} | |
| generate_release_notes: true | |
| pypi-publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release-build | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/portal-mcp-server/ | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - name: Publish release distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |