docs: add auth/ package to the architecture tree (#2012) #22
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: Publish Dev Channel | |
| on: | |
| push: | |
| branches: [master] | |
| paths-ignore: | |
| - '*.md' | |
| - 'docs/**' | |
| - '.github/workflows/close-inactive-issues.yml' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| # Restrict permissions by default | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Skip if commit is from semantic-release (version bump commits) | |
| check-skip: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_skip: ${{ steps.check.outputs.should_skip }} | |
| steps: | |
| - name: Check if should skip | |
| id: check | |
| env: | |
| # Use env var to avoid shell interpretation of backticks in commit messages | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| if [[ "$COMMIT_MSG" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || [[ "$COMMIT_MSG" =~ "chore(release)" ]]; then | |
| echo "should_skip=true" >> $GITHUB_OUTPUT | |
| echo "Skipping dev publish for release commit" | |
| else | |
| echo "should_skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| prepare: | |
| needs: check-skip | |
| if: needs.check-skip.outputs.should_skip != 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| dev_version: ${{ steps.version.outputs.dev_version }} | |
| short_sha: ${{ steps.version.outputs.short_sha }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| # Full history: the dev version number is the commit count. | |
| fetch-depth: 0 | |
| - name: Generate dev version | |
| id: version | |
| run: | | |
| # Get base version from pyproject.toml | |
| BASE_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| # dev N = commit count on master: the same commit produces the SAME | |
| # number in every workflow (PyPI/Docker in publish-dev, the dev | |
| # add-on here), so all surfaces report one dev version. run_number | |
| # was per-workflow, which is how the add-on drifted ~300 builds | |
| # behind the PyPI counter and made version reports incomparable. | |
| # Count origin/master (not HEAD): a workflow_dispatch on an older | |
| # ref would otherwise mint a LOWER number that collides with an | |
| # existing dev release and clobbers it. | |
| DEV_VERSION="${BASE_VERSION}.dev$(git rev-list --count origin/master)" | |
| echo "dev_version=$DEV_VERSION" >> $GITHUB_OUTPUT | |
| echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT | |
| echo "Dev version: $DEV_VERSION (sha: $SHORT_SHA)" | |
| publish-pypi-dev: | |
| name: Publish PyPI (dev channel) | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi-dev | |
| url: https://pypi.org/p/ha-mcp-dev | |
| permissions: | |
| contents: read | |
| id-token: write # Required for PyPI trusted publishing | |
| env: | |
| DEV_VERSION: ${{ needs.prepare.outputs.dev_version }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| submodules: true | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2 | |
| - name: Temporarily set package name and version for dev build | |
| run: | | |
| # Replace package name and version in pyproject.toml for build only | |
| sed -i 's/^name = "ha-mcp"/name = "ha-mcp-dev"/' pyproject.toml | |
| sed -i 's/^version = .*/version = "'"$DEV_VERSION"'"/' pyproject.toml | |
| # Replace package name in version lookup | |
| sed -i "s/version('ha-mcp')/version('ha-mcp-dev')/g" src/ha_mcp/__main__.py | |
| # Add ha-mcp-dev entry point with DEBUG logging | |
| sed -i '/^ha-mcp = "ha_mcp.__main__:main"$/a ha-mcp-dev = "ha_mcp.__main__:main_dev"' pyproject.toml | |
| echo "Building ha-mcp-dev version: $DEV_VERSION" | |
| grep -E '^(name|version) = ' pyproject.toml | |
| echo "Entry points:" | |
| grep -A5 '^\[project.scripts\]' pyproject.toml | |
| - name: Build distribution | |
| run: uv build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # release/v1 | |
| with: | |
| packages-dir: dist | |
| skip-existing: true | |
| publish-docker-dev: | |
| name: Publish Docker (dev channel) | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| submodules: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image (dev tags) | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| # Do NOT push :latest from dev builds. :latest is reserved for stable | |
| # releases (release-publish.yml pushes :latest + :stable together). | |
| # Dev builds run on every push to master, so tagging :latest here | |
| # clobbers the default tag with bleeding-edge dev between the biweekly | |
| # stable releases. The dev channel is :dev (rolling) + :dev-<sha>. (#1475) | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ github.repository }}:dev | |
| ${{ env.REGISTRY }}/${{ github.repository }}:dev-${{ needs.prepare.outputs.short_sha }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| BUILD_VERSION=${{ needs.prepare.outputs.dev_version }} | |
| create-prerelease: | |
| name: Create GitHub pre-release | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Create pre-release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| VERSION="${{ needs.prepare.outputs.dev_version }}" | |
| TAG="v${VERSION}" | |
| SHORT_SHA="${{ needs.prepare.outputs.short_sha }}" | |
| # Create release notes | |
| cat > release_notes.md << EOF | |
| ## Development Build | |
| **Version:** ${VERSION} | |
| **Commit:** ${SHORT_SHA} | |
| **Branch:** master | |
| This is an automated development build. Use at your own risk. | |
| For stable releases, download from the [latest release](https://github.com/${{ github.repository }}/releases/latest). | |
| ### Installation | |
| **Docker (dev channel):** | |
| \`\`\`bash | |
| docker pull ghcr.io/${{ github.repository }}:dev | |
| \`\`\` | |
| **PyPI (dev channel):** | |
| \`\`\`bash | |
| pip install ha-mcp-dev | |
| \`\`\` | |
| EOF | |
| # Delete old pre-release with same tag if exists | |
| gh release delete "$TAG" --yes 2>/dev/null || true | |
| git push origin --delete "$TAG" 2>/dev/null || true | |
| # Create new draft pre-release (binaries will be added by build-and-release workflow) | |
| gh release create "$TAG" \ | |
| --title "Dev Build $VERSION" \ | |
| --notes-file release_notes.md \ | |
| --prerelease \ | |
| --draft | |
| echo "✓ Created draft pre-release $TAG (waiting for binaries)" | |
| # Build binaries and attach to release | |
| build-and-release: | |
| needs: [prepare, create-prerelease] | |
| uses: ./.github/workflows/_build-and-release.yml | |
| with: | |
| release_tag: v${{ needs.prepare.outputs.dev_version }} | |
| is_prerelease: true | |
| permissions: | |
| contents: write | |
| cleanup-old-prereleases: | |
| name: Cleanup old pre-releases | |
| needs: build-and-release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Delete old dev releases (keep last 5) | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Get all pre-releases with .dev in the tag, sorted by date | |
| # gh release list output is tab-separated: TITLE<tab>TYPE<tab>TAG<tab>DATE | |
| gh release list --repo ${{ github.repository }} --limit 100 \ | |
| | grep -E "\.dev[0-9]+" \ | |
| | tail -n +6 \ | |
| | awk -F'\t' '{print $3}' \ | |
| | while read tag; do | |
| if [ -n "$tag" ]; then | |
| echo "Deleting old dev release: $tag" | |
| gh release delete "$tag" --yes --repo ${{ github.repository }} || true | |
| git push origin --delete "$tag" 2>/dev/null || true | |
| fi | |
| done |