fix: release workflow #4
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*' | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v5.0.0 | |
with: | |
fetch-depth: 0 # Full history for changelog | |
- name: Set up Go | |
uses: actions/setup-go@v6.0.0 | |
with: | |
go-version: '1.25' | |
- name: Cache Go modules | |
uses: actions/cache@v4.3.0 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Download dependencies | |
run: go mod download | |
- name: Verify dependencies | |
run: go mod verify | |
- name: Run tests | |
run: go test -v -short ./... | |
- name: Run GoReleaser (Release) | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: goreleaser/goreleaser-action@v6.4.0 | |
with: | |
distribution: goreleaser | |
version: v2.12.3 | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# For Homebrew tap updates (if using a separate tap repo) | |
TAP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run GoReleaser (Snapshot - PR Check) | |
if: github.event_name == 'pull_request' | |
uses: goreleaser/goreleaser-action@v6.4.0 | |
with: | |
distribution: goreleaser | |
version: v2.12.3 | |
args: release --snapshot --clean --skip=publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload release summary (Release) | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo "## 🎉 Release ${{ github.ref_name }} Published!" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### 📦 Assets Built:" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Linux (amd64, arm64)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ macOS (amd64, arm64)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Windows (amd64)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Checksums generated" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### 🚀 Installation:" >> $GITHUB_STEP_SUMMARY | |
echo '```bash' >> $GITHUB_STEP_SUMMARY | |
echo "# Download binary for your platform from release assets above" >> $GITHUB_STEP_SUMMARY | |
echo "# Extract and verify:" >> $GITHUB_STEP_SUMMARY | |
echo "kubectx-manager version" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
- name: Upload build summary (PR Check) | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "## ✅ Release Build Validation Successful!" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### 🧪 PR Release Check Results:" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ GoReleaser configuration is valid" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ All cross-platform builds successful" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Tests passed (unit tests only)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Dependencies verified" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### 📦 Build Validation:" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Linux (amd64, arm64)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ macOS (amd64, arm64)" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Windows (amd64)" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "🚀 **Ready for release!** The next tag push will create a real release." |