Merge pull request #32 from reporails/0.5.11 #33
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 | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| check-release: | |
| name: Check if release commit | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_release: ${{ steps.check.outputs.is_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Detect version branch merge | |
| id: check | |
| run: | | |
| VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| # Check if this push is a merge from a version branch | |
| MERGE_BRANCH=$(git log -1 --pretty=%s | grep -oP 'Merge.*from.*\K[0-9]+\.[0-9]+\.[0-9]+' || true) | |
| if [ "$MERGE_BRANCH" = "$VERSION" ]; then | |
| echo "is_release=true" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Release detected: $VERSION" | |
| else | |
| echo "is_release=false" >> "$GITHUB_OUTPUT" | |
| echo "Not a release merge (merge_branch=$MERGE_BRANCH, version=$VERSION)" | |
| fi | |
| qa: | |
| name: QA gate (${{ matrix.os }}) | |
| needs: check-release | |
| if: needs.check-release.outputs.is_release == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Lint | |
| run: uv run poe lint | |
| - name: Type check (host platform) | |
| run: uv run poe type | |
| - name: Type check (cross-platform) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: uv run mypy --platform=win32 src/ | |
| - name: Unit tests | |
| run: uv run poe test_unit | |
| - name: Integration tests | |
| run: uv run poe test_integration | |
| # Smoke tests intentionally not gated in CI yet — environment-dependent. | |
| # Re-enable once the smoke suite is hermetic. | |
| build: | |
| name: Build wheel + sdist | |
| needs: [check-release, qa] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Fetch bundled ONNX model | |
| run: uv run poe fetch_bundled_model | |
| - name: Build package | |
| run: | | |
| # Build wheel directly from source tree (not via sdist) so the | |
| # gitignored ONNX model is picked up by the build hook. | |
| uv build --wheel | |
| # sdist separately for PyPI (model not included — source-only) | |
| uv build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| verify-wheel: | |
| name: Verify wheel (${{ matrix.os }}) | |
| needs: build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install wheel in fresh venv (cross-platform) | |
| run: | | |
| python -m venv venv-verify | |
| python -c " | |
| import glob, subprocess, sys | |
| from pathlib import Path | |
| venv = Path('venv-verify') | |
| pip = venv / ('Scripts' if sys.platform == 'win32' else 'bin') / ('pip.exe' if sys.platform == 'win32' else 'pip') | |
| wheels = glob.glob('dist/*.whl') | |
| assert len(wheels) == 1, f'Expected 1 wheel, got {wheels}' | |
| subprocess.run([str(pip), 'install', wheels[0], '--quiet'], check=True) | |
| " | |
| shell: bash | |
| - name: Smoke check + ONNX model present | |
| run: | | |
| python -c " | |
| import subprocess, sys | |
| from pathlib import Path | |
| venv = Path('venv-verify') | |
| ails = venv / ('Scripts' if sys.platform == 'win32' else 'bin') / ('ails.exe' if sys.platform == 'win32' else 'ails') | |
| py = venv / ('Scripts' if sys.platform == 'win32' else 'bin') / ('python.exe' if sys.platform == 'win32' else 'python') | |
| subprocess.run([str(ails), 'version'], check=True) | |
| subprocess.run([str(ails), 'check', '--help'], check=True, stdout=subprocess.DEVNULL) | |
| subprocess.run([str(py), '-c', | |
| 'from reporails_cli.bundled import get_models_path;' | |
| 'onnx = get_models_path() / \"minilm-l6-v2\" / \"onnx\" / \"model.onnx\";' | |
| 'assert onnx.exists(), f\"ONNX missing: {onnx}\";' | |
| 'print(f\"ONNX OK: {onnx.stat().st_size // 1024 // 1024} MB\")' | |
| ], check=True) | |
| " | |
| shell: bash | |
| publish: | |
| name: Publish to PyPI | |
| needs: [check-release, verify-wheel] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| environment: release | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| npm: | |
| name: Publish to npm | |
| needs: [check-release, publish] | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| defaults: | |
| run: | |
| working-directory: packages/npm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Set version | |
| run: | | |
| VERSION="${{ needs.check-release.outputs.version }}" | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Publish to npm | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| tag: | |
| name: Tag and GitHub release | |
| needs: [check-release, publish, npm] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create tag and GitHub release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.check-release.outputs.version }}" | |
| git tag "$VERSION" | |
| git push origin "$VERSION" | |
| gh release create "$VERSION" \ | |
| --title "v$VERSION" \ | |
| --generate-notes |