infer packagfe version from the git tag #8
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: Publish | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" # Triggers on version tags like v1.2.3 | |
| jobs: | |
| build-and-publish: | |
| name: Build and Publish to PyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Init | |
| run: make init | |
| - name: Install dependencies | |
| run: make install | |
| - name: Run checks | |
| run: make check | |
| - name: Run tests | |
| run: make test | |
| - name: Configure Poetry | |
| run: | | |
| poetry config virtualenvs.create true | |
| poetry config virtualenvs.in-project true | |
| poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
| - name: Set version from tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF_NAME#v} | |
| echo "Setting version to $TAG_VERSION in pyproject.toml" | |
| sed -i "s/^version = \".*\"/version = \"$TAG_VERSION\"/" pyproject.toml | |
| - name: Build package | |
| run: make build | |
| - name: Publish to PyPI | |
| run: make publish | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |