Improve Karpenter log analyzer for reconciler and admission webhook e… #33
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Generate changelog | |
| id: changelog | |
| continue-on-error: true | |
| uses: metcalfc/changelog-generator@v4.4.0 | |
| with: | |
| myToken: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Read CHANGELOG.md as fallback | |
| id: changelog-fallback | |
| if: steps.changelog.outcome == 'failure' || steps.changelog.outputs.changelog == '' | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| if [ -f CHANGELOG.md ]; then | |
| # Extract changelog for this version from CHANGELOG.md | |
| # Look for the version section and extract until next version or end | |
| awk -v version="$VERSION" ' | |
| /^## \[' version '\]/ { found=1; next } | |
| found && /^## \[/ { exit } | |
| found { print } | |
| ' CHANGELOG.md > /tmp/changelog.txt || echo "Initial release" > /tmp/changelog.txt | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| cat /tmp/changelog.txt >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "changelog=Initial release" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Install swag CLI | |
| run: go install github.com/swaggo/swag/cmd/swag@latest | |
| - name: Generate Swagger docs | |
| run: | | |
| export PATH=$PATH:$(go env GOPATH)/bin | |
| swag init -g cmd/api/main.go -o ./docs/swagger | |
| - name: Cache Go build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/go-build | |
| key: ${{ runner.os }}-go-build-${{ hashFiles('**/*.go') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-build- | |
| - name: Build binaries (parallel) | |
| run: | | |
| mkdir -p dist | |
| # Build all binaries in parallel using background jobs | |
| GOOS=linux GOARCH=amd64 go build -o dist/karpenter-optimizer-api-linux-amd64 ./cmd/api & | |
| GOOS=linux GOARCH=arm64 go build -o dist/karpenter-optimizer-api-linux-arm64 ./cmd/api & | |
| GOOS=darwin GOARCH=amd64 go build -o dist/karpenter-optimizer-api-darwin-amd64 ./cmd/api & | |
| GOOS=darwin GOARCH=arm64 go build -o dist/karpenter-optimizer-api-darwin-arm64 ./cmd/api & | |
| GOOS=windows GOARCH=amd64 go build -o dist/karpenter-optimizer-api-windows-amd64.exe ./cmd/api & | |
| wait | |
| ls -lh dist/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ steps.version.outputs.version }} | |
| body: | | |
| ## Changes in this Release | |
| ${{ steps.changelog.outputs.changelog || steps.changelog-fallback.outputs.changelog || 'See CHANGELOG.md for details' }} | |
| ## Docker Images | |
| - `ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}` | |
| - `ghcr.io/${{ github.repository }}-frontend:${{ steps.version.outputs.version }}` | |
| ## Helm Chart | |
| ```bash | |
| helm repo add karpenter-optimizer https://kaskol10.github.io/karpenter-optimizer | |
| helm repo update | |
| helm install karpenter-optimizer karpenter-optimizer/karpenter-optimizer --version ${{ steps.version.outputs.version }} | |
| ``` | |
| ## Binaries | |
| Pre-built binaries are available in the assets below for Linux (amd64/arm64), macOS (amd64/arm64), and Windows (amd64). | |
| files: | | |
| dist/karpenter-optimizer-api-linux-amd64 | |
| dist/karpenter-optimizer-api-linux-arm64 | |
| dist/karpenter-optimizer-api-darwin-amd64 | |
| dist/karpenter-optimizer-api-darwin-arm64 | |
| dist/karpenter-optimizer-api-windows-amd64.exe | |
| draft: false | |
| prerelease: false | |
| publish-helm-chart: | |
| name: Publish Helm Chart | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: '3.13.0' | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Update Chart.yaml version | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| sed -i "s/^version:.*/version: $VERSION/" charts/karpenter-optimizer/Chart.yaml | |
| sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" charts/karpenter-optimizer/Chart.yaml | |
| echo "Updated Chart.yaml:" | |
| cat charts/karpenter-optimizer/Chart.yaml | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit Chart.yaml changes | |
| run: | | |
| git add charts/karpenter-optimizer/Chart.yaml | |
| if git diff --staged --quiet; then | |
| echo "No changes to Chart.yaml" | |
| else | |
| git commit -m "chore: bump Helm chart version to ${{ steps.version.outputs.version }}" | |
| git push origin HEAD:main || echo "Failed to push Chart.yaml changes (may already be committed)" | |
| fi | |
| - name: Package Chart | |
| run: | | |
| helm package charts/karpenter-optimizer --destination ./charts | |
| ls -lh charts/*.tgz | |
| helm show chart charts/karpenter-optimizer-*.tgz | |
| - name: Checkout gh-pages branch | |
| run: | | |
| git fetch origin gh-pages:gh-pages 2>/dev/null || echo "gh-pages branch does not exist yet" | |
| git checkout gh-pages 2>/dev/null || git checkout -b gh-pages | |
| - name: Generate Index | |
| run: | | |
| # Copy new chart package to root (not in subdirectories) | |
| cp charts/karpenter-optimizer-*.tgz . || true | |
| # Remove any .tgz files from subdirectories to avoid incorrect URLs | |
| rm -f charts/*.tgz || true | |
| # Fix any existing incorrect URLs in index.yaml (remove /charts/ prefix) | |
| if [ -f index.yaml ]; then | |
| sed -i 's|https://kaskol10.github.io/karpenter-optimizer/charts/|https://kaskol10.github.io/karpenter-optimizer/|g' index.yaml | |
| sed -i 's|urls:.*/charts/|urls:|g' index.yaml || true | |
| fi | |
| # Generate or update index.yaml | |
| # Use --url without trailing slash to ensure correct paths | |
| if [ -f index.yaml ]; then | |
| helm repo index . --url https://kaskol10.github.io/karpenter-optimizer --merge index.yaml | |
| else | |
| helm repo index . --url https://kaskol10.github.io/karpenter-optimizer | |
| fi | |
| # Fix any URLs that still have /charts/ (shouldn't happen, but just in case) | |
| sed -i 's|https://kaskol10.github.io/karpenter-optimizer/charts/|https://kaskol10.github.io/karpenter-optimizer/|g' index.yaml || true | |
| # Verify URLs in index.yaml don't have /charts/ subdirectory | |
| if grep -q '/charts/' index.yaml; then | |
| echo "ERROR: index.yaml still contains incorrect /charts/ paths after fix!" | |
| cat index.yaml | |
| exit 1 | |
| fi | |
| # Show what was generated | |
| echo "Generated index.yaml:" | |
| cat index.yaml | |
| - name: Commit and Push to gh-pages | |
| run: | | |
| git add index.yaml *.tgz 2>/dev/null || true | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit to gh-pages" | |
| else | |
| git commit -m "Add Helm chart version ${{ steps.version.outputs.version }}" | |
| git push origin gh-pages | |
| echo "✅ Published Helm chart version ${{ steps.version.outputs.version }}" | |
| fi | |