release: prepare v0.0.1 release #1
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: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| test-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true | |
| attestations: true | |
| build-and-publish: | |
| needs: test-publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true | |
| attestations: true | |
| create-release: | |
| needs: build-and-publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Extract changelog for version | |
| id: extract_changelog | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.VERSION }} | |
| # Extract changelog section for this version | |
| CHANGELOG_SECTION=$(awk -v ver="$VERSION" ' | |
| BEGIN { in_section = 0; section = ""; } | |
| /^## \[[0-9]+\.[0-9]+\.[0-9]+/ { | |
| if (in_section) { exit; } | |
| if ($0 ~ ver) { in_section = 1; } | |
| } | |
| in_section { section = section $0 "\n"; } | |
| END { print section; } | |
| ' CHANGELOG.md) | |
| # If no specific version section found, use Unreleased section | |
| if [ -z "$CHANGELOG_SECTION" ]; then | |
| CHANGELOG_SECTION=$(awk ' | |
| BEGIN { in_section = 0; section = ""; } | |
| /^## \[Unreleased\]/ { in_section = 1; } | |
| /^## \[[0-9]+\.[0-9]+\.[0-9]+/ { if (in_section) { exit; } } | |
| in_section { section = section $0 "\n"; } | |
| END { print section; } | |
| ' CHANGELOG.md) | |
| fi | |
| # Save to output, handling multiline strings | |
| echo "CHANGELOG_SECTION<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG_SECTION" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Generate release notes | |
| id: generate_release_notes | |
| uses: mikepenz/release-changelog-builder-action@v4 | |
| with: | |
| configuration: | | |
| { | |
| "categories": [ | |
| { | |
| "title": "## 🚀 Features", | |
| "labels": ["feature", "enhancement"] | |
| }, | |
| { | |
| "title": "## 🐛 Fixes", | |
| "labels": ["fix", "bug"] | |
| }, | |
| { | |
| "title": "## 📚 Documentation", | |
| "labels": ["documentation"] | |
| }, | |
| { | |
| "title": "## 🧪 Tests", | |
| "labels": ["test"] | |
| }, | |
| { | |
| "title": "## 🔧 Maintenance", | |
| "labels": ["chore", "dependencies"] | |
| } | |
| ] | |
| } | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: Release v${{ steps.get_version.outputs.VERSION }} | |
| body: | | |
| # Release v${{ steps.get_version.outputs.VERSION }} | |
| ## Changelog | |
| ${{ steps.extract_changelog.outputs.CHANGELOG_SECTION }} | |
| ## Pull Requests | |
| ${{ steps.generate_release_notes.outputs.changelog }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |