Bump version to 0.0.4 in pyproject.toml and update Git configuration … #6
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: Build, Tag & Publish Pixelcore | |
| # Only trigger on push to master | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| tag-build-publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
| steps: | |
| # 1. Checkout code | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # 2. Set up Python | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| # 3. Install dependencies for building | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install toml build twine | |
| # 4. Read version from pyproject.toml | |
| - name: Read package version | |
| id: get_version | |
| run: | | |
| VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Version read from pyproject.toml: $VERSION" | |
| # 5. Auto-tag if tag does not exist | |
| - name: Create tag if missing | |
| id: tag | |
| run: | | |
| # Configure Git user/email for tags | |
| git config --global user.name "github-actions" | |
| git config --global user.email "github-actions@github.com" | |
| # Create tag only if it does not exist | |
| if ! git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| echo "Tag v$VERSION not found. Creating tag..." | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push origin "v$VERSION" | |
| else | |
| echo "Tag v$VERSION already exists." | |
| fi | |
| # 6. Build distributions | |
| - name: Build package | |
| run: python -m build | |
| # 7. Optionally, run tests before publishing | |
| # - name: Run tests | |
| # run: | | |
| # python -m pip install -e .[dev] | |
| # pytest tests | |
| # 8. Publish to PyPI | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ env.PYPI_API_TOKEN }} |