Release v0.1.2 #17
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: CI/CD | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [published] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.12 | |
| - uses: astral-sh/ruff-action@v3 | |
| - run: ruff check . | |
| - run: ruff format --check . | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies and run tests | |
| run: | | |
| uv venv | |
| source .venv/bin/activate | |
| uv sync | |
| pytest -v | |
| publish: | |
| if: github.event_name == 'release' | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.12" | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install build dependencies | |
| run: | | |
| uv tool install build | |
| uv tool install twine | |
| - name: Extract version from release tag | |
| id: get_version | |
| run: | | |
| # Remove 'v' prefix if present and set version | |
| VERSION=${GITHUB_REF_NAME#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Update version in pyproject.toml | |
| run: | | |
| sed -i 's/^version = .*/version = "${{ steps.get_version.outputs.version }}"/' pyproject.toml | |
| - name: Update version in __init__.py | |
| run: | | |
| sed -i 's/^__version__ = .*/__version__ = "${{ steps.get_version.outputs.version }}"/' pyjavapoet/__init__.py | |
| - name: Verify version update | |
| run: | | |
| echo "pyproject.toml version:" | |
| grep "^version = " pyproject.toml | |
| echo "__init__.py version:" | |
| grep "^__version__ = " pyjavapoet/__init__.py | |
| - name: Build package | |
| run: | | |
| uv tool run --from build pyproject-build | |
| - name: Check package contents | |
| run: | | |
| uv tool run twine check dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true | |
| verbose: true | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-files | |
| path: dist/ | |
| retention-days: 30 |