[Version] Bump version to 1.0.1 in pyproject.toml and __init__.py #7
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 | |
| # Trigger when version files are modified or via manual dispatch | |
| on: | |
| push: | |
| # Only trigger when the two files that declare the package version are changed | |
| paths: | |
| - 'pyproject.toml' | |
| - 'src/quanteval/__init__.py' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'If "true", publish to TestPyPI (requires TEST_PYPI_TOKEN).' | |
| required: false | |
| default: 'false' | |
| permissions: | |
| contents: write | |
| packages: write | |
| # allow creating tags/releases | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| cache: pip | |
| - name: Check version bump in pyproject.toml and __init__.py | |
| id: check | |
| env: | |
| GITHUB_BEFORE: ${{ github.event.before }} | |
| GITHUB_AFTER: ${{ github.sha }} | |
| run: | | |
| set -euo pipefail | |
| python .github/scripts/check_version_bump.py | |
| - name: Stop if not a release commit | |
| if: ${{ steps.check.outputs.should_release == 'false' }} | |
| run: | | |
| echo "No version bump detected or versions do not match; skipping release." | |
| exit 0 | |
| - name: Create tag for release | |
| if: ${{ steps.check.outputs.should_release == 'true' }} | |
| env: | |
| VERSION: ${{ steps.check.outputs.version }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| TAG=v${VERSION} | |
| # avoid error if tag already exists | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists, skipping tag creation." | |
| else | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| fi | |
| - name: Install build dependencies | |
| if: ${{ steps.check.outputs.should_release == 'true' }} | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e ".[dev]" | |
| - name: Build release artifacts | |
| if: ${{ steps.check.outputs.should_release == 'true' }} | |
| run: python -m build | |
| - name: Validate artifacts | |
| if: ${{ steps.check.outputs.should_release == 'true' }} | |
| run: twine check dist/* | |
| - name: Publish to TestPyPI (dry-run) | |
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true' && steps.check.outputs.should_release == 'true' }} | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install twine | |
| twine upload --repository-url https://test.pypi.org/legacy/ dist/* -u __token__ -p ${{ secrets.TEST_PYPI_TOKEN }} --skip-existing --verbose | |
| - name: Publish to PyPI | |
| if: ${{ steps.check.outputs.should_release == 'true' && !(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true') }} | |
| uses: pypa/gh-action-pypi-publish@v1.5.0 | |
| with: | |
| skip-existing: true | |
| verbose: true | |
| user: __token__ | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| - name: Create GitHub release | |
| if: ${{ steps.check.outputs.should_release == 'true' }} | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.check.outputs.version }} | |
| name: Release v${{ steps.check.outputs.version }} | |
| generate_release_notes: true | |
| files: | | |
| dist/* |