Skip to content

Fix 3 SonarCloud reliability bugs #26

Fix 3 SonarCloud reliability bugs

Fix 3 SonarCloud reliability bugs #26

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: |
# Derive base version from latest stable release tag (e.g. v0.0.1 -> 0.0.1)
STABLE_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" --sort=-v:refname | grep -vE 'b[0-9]+$' | head -n1)
if [ -n "$STABLE_TAG" ]; then
BASE="${STABLE_TAG#v}"
else
BASE=$(python3 -c "import tomli; print(tomli.load(open('pyproject.toml','rb'))['project']['version'])")
fi
# Find latest beta tag number (PEP 440: v0.0.1b0, v0.0.1b1, ...)
LATEST=$(git tag -l "v${BASE}b*" --sort=-v:refname | head -n1)
if [ -n "$LATEST" ]; then
LAST_NUM=$(echo "$LATEST" | sed "s/v${BASE}b//")
BETA_NUM=$((LAST_NUM + 1))
else
BETA_NUM=0
fi
PEP_VERSION="${BASE}b${BETA_NUM}"
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=$PEP_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v${PEP_VERSION}" >> "$GITHUB_OUTPUT"
echo "sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "Beta version: v${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(\"osscodeiq\")}')"
python -c "from osscodeiq.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_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_PEP} (${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}/osscodeiq-${BETA_PEP}-py3-none-any.whl
\`\`\`
**Or with osscodeiq CLI:**
\`\`\`bash
osscodeiq version
osscodeiq analyze /path/to/repo
\`\`\`" \
--prerelease