Update version to 1.0.166, expand excluded modules in Blinter.spec fo… #165
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-Release-PYPI" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - pyproject.toml | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| check-version: | |
| name: Check pyproject.toml version bump | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 2 | |
| - name: Read version from pyproject.toml | |
| id: version | |
| run: | | |
| VERSION=$(python -c "import pathlib; p=pathlib.Path('pyproject.toml'); print(next(l.split('=',1)[1].strip().strip('\"').strip(\"'\") for l in p.read_text().splitlines() if l.strip().startswith('version = ')))") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Project version: $VERSION" | |
| - name: Decide whether to release | |
| id: check | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "Manual workflow_dispatch; releasing version ${{ steps.version.outputs.version }}." | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| OLD_VERSION=$(python -c " | |
| import pathlib, subprocess, sys | |
| text = subprocess.check_output(['git', 'show', 'HEAD^:pyproject.toml'], text=True) | |
| for line in text.splitlines(): | |
| stripped = line.strip() | |
| if stripped.startswith('version = '): | |
| print(stripped.split('=', 1)[1].strip().strip('\"').strip(\"'\")) | |
| break | |
| else: | |
| sys.exit('Could not read previous version from pyproject.toml') | |
| ") | |
| NEW_VERSION="${{ steps.version.outputs.version }}" | |
| if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then | |
| echo "Version unchanged ($NEW_VERSION); skipping release." | |
| echo "should_release=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Version bumped: $OLD_VERSION -> $NEW_VERSION" | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| verify: | |
| name: Verify before release | |
| needs: check-version | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e ".[dev]" | |
| - name: Run quality checks | |
| run: | | |
| python -m black --check src tests scripts | |
| python -m isort --check-only src tests scripts | |
| python -m mypy src/blinter tests scripts/verify.py scripts/corpus_lint.py scripts/corpus_baseline.py scripts/generate_corpus_baseline.py | |
| python -m pylint src/blinter | |
| python -m bandit -r src/blinter -c pyproject.toml -ll -q | |
| - name: Run tests | |
| run: python -m pytest | |
| build-windows: | |
| needs: [check-version, verify] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Read version from pyproject.toml | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $match = Select-String -Path "pyproject.toml" -Pattern '^version = "(.+)"' | |
| if (-not $match) { throw "Could not read version from pyproject.toml" } | |
| $version = $match.Matches[0].Groups[1].Value | |
| "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Create virtual environment | |
| run: python -m venv venv | |
| - name: Install dependencies in virtual environment | |
| run: | | |
| .\venv\Scripts\Activate.ps1 | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade setuptools | |
| python -m pip install --upgrade wheel | |
| python -m pip install --upgrade pyinstaller | |
| python -m pip install --upgrade -r requirements.txt | |
| shell: pwsh | |
| - name: Generate version info file | |
| run: | | |
| .\venv\Scripts\Activate.ps1 | |
| python scripts/generate_file_version_info.py | |
| shell: pwsh | |
| - name: Build executable | |
| run: | | |
| .\venv\Scripts\Activate.ps1 | |
| pyinstaller Blinter.spec | |
| shell: pwsh | |
| - name: Rename executable | |
| run: | | |
| Rename-Item -Path dist/Blinter.exe -NewName "Blinter-v${{ steps.version.outputs.version }}.exe" | |
| shell: pwsh | |
| - name: Zip the exe | |
| run: | | |
| Compress-Archive -Path "dist/Blinter-v${{ steps.version.outputs.version }}.exe" -DestinationPath "dist/Blinter-v${{ steps.version.outputs.version }}.zip" | |
| shell: pwsh | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: windows-build | |
| path: dist/Blinter-v${{ steps.version.outputs.version }}.zip | |
| build-wheels: | |
| name: Build Python wheels | |
| needs: [check-version, verify] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade setuptools | |
| python -m pip install --upgrade wheel | |
| python -m pip install --upgrade build | |
| - name: Build pure Python wheel and sdist | |
| run: python -m build | |
| - name: Store artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: python-dist | |
| path: dist/ | |
| create-release: | |
| needs: [check-version, verify, build-windows] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Download Windows build | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: windows-build | |
| path: ./build | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: ./build/Blinter-v${{ needs.check-version.outputs.version }}.zip | |
| tag: v${{ needs.check-version.outputs.version }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| allowUpdates: true | |
| removeArtifacts: true | |
| publish-pypi: | |
| name: Publish wheels to PyPI | |
| needs: [check-version, verify, build-wheels] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: python-dist | |
| path: dist | |
| - name: Setup python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Install Twine | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade setuptools | |
| python -m pip install --upgrade wheel | |
| python -m pip install --upgrade twine | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_BLINTER }} | |
| run: | | |
| twine check dist/* | |
| twine upload dist/* |