Skip to content

Add .codeignore + .gitignore support, fix node_modules exclude bug #5

Add .codeignore + .gitignore support, fix node_modules exclude bug

Add .codeignore + .gitignore support, fix node_modules exclude bug #5

Workflow file for this run

name: Publish Beta
on:
push:
branches: [main]
paths:
- "src/**"
- "tests/**"
- "pyproject.toml"
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
build-and-publish:
name: Build & publish beta
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install build tomli
- name: Compute beta version
id: version
run: |
BASE=$(python3 -c "import tomli; print(tomli.load(open('pyproject.toml','rb'))['project']['version'])")
if git describe --tags --match "v*" HEAD 2>/dev/null; then
BETA_NUM=$(git rev-list "$(git describe --tags --match 'v*' --abbrev=0 HEAD)"..HEAD --count)
else
BETA_NUM=$(git rev-list HEAD --count)
fi
# PEP 440 beta: 0.1.0b0, 0.1.0b1, ...
PEP_VERSION="${BASE}b${BETA_NUM}"
# Display: 0.1.0-beta.0, 0.1.0-beta.1, ...
DISPLAY_VERSION="${BASE}-beta.${BETA_NUM}"
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=$PEP_VERSION" >> "$GITHUB_OUTPUT"
echo "display=$DISPLAY_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v${DISPLAY_VERSION}" >> "$GITHUB_OUTPUT"
echo "sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "Beta version: $DISPLAY_VERSION ($PEP_VERSION) @ ${SHORT_SHA}"
- name: Patch version in pyproject.toml
env:
BETA_VERSION: ${{ steps.version.outputs.version }}
run: |
python3 << 'PYEOF'
import os, re
ver = os.environ["BETA_VERSION"]
with open("pyproject.toml", "r") as f:
content = f.read()
content = re.sub(r'version\s*=\s*"[^"]+"', f'version = "{ver}"', content, count=1)
with open("pyproject.toml", "w") as f:
f.write(content)
PYEOF
- name: Build wheel and sdist
run: python -m build
- name: Verify wheel
run: |
pip install dist/*.whl
python -c "import importlib.metadata; print(f'Built: {importlib.metadata.version(\"code-intelligence\")}')"
python -c "from code_intelligence.detectors.registry import DetectorRegistry; r = DetectorRegistry(); r.load_builtin_detectors(); print(f'{len(r.all_detectors())} detectors')"
- name: Delete existing beta tag (if any)
env:
BETA_TAG: ${{ steps.version.outputs.tag }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete "$BETA_TAG" --yes 2>/dev/null || true
git push origin ":refs/tags/$BETA_TAG" 2>/dev/null || true
- name: Create beta release with wheel
env:
BETA_TAG: ${{ steps.version.outputs.tag }}
BETA_DISPLAY: ${{ steps.version.outputs.display }}
BETA_PEP: ${{ steps.version.outputs.version }}
BETA_SHA: ${{ steps.version.outputs.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$BETA_TAG" dist/* \
--title "$BETA_DISPLAY ($BETA_SHA)" \
--notes "Auto-generated beta build from commit $BETA_SHA.
**Install:**
\`\`\`bash
pip install https://github.com/RandomCodeSpace/code-iq/releases/download/${BETA_TAG}/code_intelligence-${BETA_PEP}-py3-none-any.whl
\`\`\`
**Or with code-iq CLI:**
\`\`\`bash
code-iq version
code-iq analyze /path/to/repo
\`\`\`" \
--prerelease