|
| 1 | +name: Publish Beta |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "src/**" |
| 8 | + - "tests/**" |
| 9 | + - "pyproject.toml" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + packages: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-publish: |
| 17 | + name: Build & publish beta |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: "3.12" |
| 28 | + |
| 29 | + - name: Install build tools |
| 30 | + run: pip install build tomli |
| 31 | + |
| 32 | + - name: Compute beta version |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + BASE=$(python3 -c "import tomli; print(tomli.load(open('pyproject.toml','rb'))['project']['version'])") |
| 36 | + if git describe --tags --match "v*" HEAD 2>/dev/null; then |
| 37 | + BETA_NUM=$(git rev-list "$(git describe --tags --match 'v*' --abbrev=0 HEAD)"..HEAD --count) |
| 38 | + else |
| 39 | + BETA_NUM=$(git rev-list HEAD --count) |
| 40 | + fi |
| 41 | + VERSION="${BASE}.dev${BETA_NUM}" |
| 42 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 43 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 44 | + echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" |
| 45 | + echo "sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" |
| 46 | + echo "Beta version: $VERSION (${SHORT_SHA})" |
| 47 | +
|
| 48 | + - name: Patch version in pyproject.toml |
| 49 | + env: |
| 50 | + BETA_VERSION: ${{ steps.version.outputs.version }} |
| 51 | + run: | |
| 52 | + python3 << 'PYEOF' |
| 53 | + import os, re |
| 54 | + ver = os.environ["BETA_VERSION"] |
| 55 | + with open("pyproject.toml", "r") as f: |
| 56 | + content = f.read() |
| 57 | + content = re.sub(r'version\s*=\s*"[^"]+"', f'version = "{ver}"', content, count=1) |
| 58 | + with open("pyproject.toml", "w") as f: |
| 59 | + f.write(content) |
| 60 | + PYEOF |
| 61 | +
|
| 62 | + - name: Build wheel and sdist |
| 63 | + run: python -m build |
| 64 | + |
| 65 | + - name: Verify wheel |
| 66 | + run: | |
| 67 | + pip install dist/*.whl |
| 68 | + python -c "import importlib.metadata; print(f'Built: {importlib.metadata.version(\"code-intelligence\")}')" |
| 69 | + python -c "from code_intelligence.detectors.registry import DetectorRegistry; r = DetectorRegistry(); r.load_builtin_detectors(); print(f'{len(r.all_detectors())} detectors')" |
| 70 | +
|
| 71 | + - name: Delete existing beta tag (if any) |
| 72 | + env: |
| 73 | + BETA_TAG: ${{ steps.version.outputs.tag }} |
| 74 | + run: | |
| 75 | + gh release delete "$BETA_TAG" --yes 2>/dev/null || true |
| 76 | + git push origin ":refs/tags/$BETA_TAG" 2>/dev/null || true |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + |
| 80 | + - name: Create beta release with wheel |
| 81 | + env: |
| 82 | + BETA_TAG: ${{ steps.version.outputs.tag }} |
| 83 | + BETA_VERSION: ${{ steps.version.outputs.version }} |
| 84 | + BETA_SHA: ${{ steps.version.outputs.sha }} |
| 85 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + run: | |
| 87 | + gh release create "$BETA_TAG" dist/* \ |
| 88 | + --title "Beta $BETA_VERSION ($BETA_SHA)" \ |
| 89 | + --notes "Auto-generated beta build from commit $BETA_SHA. Install with: pip install https://github.com/RandomCodeSpace/code-iq/releases/download/$BETA_TAG/code_intelligence-${BETA_VERSION}-py3-none-any.whl" \ |
| 90 | + --prerelease |
0 commit comments