Merge pull request #5 from BinarCode/revert-copilot-support #21
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: Auto Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write # Required for trusted publishing to PyPI | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get version from pyproject.toml | |
| id: version | |
| run: | | |
| VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version from pyproject.toml: $VERSION" | |
| - name: Check if version already released | |
| id: check | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if git tag | grep -q "^v$VERSION$"; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "Version v$VERSION already exists, skipping" | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| echo "Version v$VERSION not released yet" | |
| fi | |
| - name: Create tag and release | |
| if: steps.check.outputs.skip == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| COMMIT_MSG=$(git log -1 --pretty=%B | head -1) | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push origin "v$VERSION" | |
| cat <<EOF | gh release create "v$VERSION" --title "v$VERSION" --notes-file - | |
| ## Changes | |
| $COMMIT_MSG | |
| --- | |
| *Auto-generated release* | |
| EOF | |
| # Publish to PyPI | |
| - name: Install uv | |
| if: steps.check.outputs.skip == 'false' | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| if: steps.check.outputs.skip == 'false' | |
| run: uv python install 3.11 | |
| - name: Build package | |
| if: steps.check.outputs.skip == 'false' | |
| run: uv build | |
| - name: Publish to PyPI | |
| if: steps.check.outputs.skip == 'false' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true | |
| # Update Homebrew formula | |
| - name: Get release info for Homebrew | |
| if: steps.check.outputs.skip == 'false' | |
| id: homebrew | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| URL="https://github.com/${{ github.repository }}/archive/refs/tags/v$VERSION.tar.gz" | |
| SHA256=$(curl -sL "$URL" | shasum -a 256 | cut -d' ' -f1) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "url=$URL" >> $GITHUB_OUTPUT | |
| echo "sha256=$SHA256" >> $GITHUB_OUTPUT | |
| echo "Homebrew URL: $URL" | |
| echo "Homebrew SHA256: $SHA256" | |
| - name: Checkout homebrew-aidocs | |
| if: steps.check.outputs.skip == 'false' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: binarcode/homebrew-aidocs | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-aidocs | |
| - name: Update Homebrew formula | |
| if: steps.check.outputs.skip == 'false' | |
| run: | | |
| cat > homebrew-aidocs/Formula/aidocs.rb << EOF | |
| class Aidocs < Formula | |
| include Language::Python::Virtualenv | |
| desc "AI-powered documentation generator CLI for Claude Code" | |
| homepage "https://github.com/binarcode/aidocs-cli" | |
| url "${{ steps.homebrew.outputs.url }}" | |
| sha256 "${{ steps.homebrew.outputs.sha256 }}" | |
| license "MIT" | |
| depends_on "python@3.11" | |
| def install | |
| venv = virtualenv_create(libexec, "python3.11") | |
| venv.pip_install "aidocs==${{ steps.homebrew.outputs.version }}" | |
| bin.install_symlink libexec/"bin/aidocs" | |
| end | |
| test do | |
| assert_match "aidocs", shell_output("#{bin}/aidocs version") | |
| end | |
| end | |
| EOF | |
| - name: Commit and push Homebrew formula | |
| if: steps.check.outputs.skip == 'false' | |
| run: | | |
| cd homebrew-aidocs | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add Formula/aidocs.rb | |
| git diff --staged --quiet || git commit -m "Update aidocs to ${{ steps.homebrew.outputs.version }}" | |
| git push |