Skip to content

fix(ccache): make CI cache persistence possible and observable #66

fix(ccache): make CI cache persistence possible and observable

fix(ccache): make CI cache persistence possible and observable #66

Workflow file for this run

name: 🚀 Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release"
required: true
type: string
permissions:
contents: write
packages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
GO_VERSION: "1.26.4"
REGISTRY: ghcr.io
jobs:
# ===================================
# Pre-Release Validation
# ===================================
validate:
name: 🔍 Pre-Release Validation
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.version.outputs.version }}
is-prerelease: ${{ steps.version.outputs.is-prerelease }}
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🏷️ Get version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
# Check if this is a prerelease
if [[ "$VERSION" =~ -[a-zA-Z] ]]; then
echo "is-prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is-prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "📋 Version: ${VERSION}"
echo "📋 Pre-release: $([[ "$VERSION" =~ -[a-zA-Z] ]] && echo 'true' || echo 'false')"
- name: 🐹 Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: ✅ Validate build
run: |
go mod download
go build -v ./...
go test -v ./...
# ===================================
# Binary Release with GoReleaser
# ===================================
goreleaser:
name: 🔨 Build & Release Binaries
runs-on: ubuntu-latest
timeout-minutes: 30
needs: validate
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🐹 Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: 🔨 Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 📤 Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: release-artifacts
path: dist/
retention-days: 30
# ===================================
# Package Registry Publishing
# ===================================
packages:
name: 📦 Publish Packages
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [validate, goreleaser]
if: github.ref_type == 'tag' && needs.validate.outputs.is-prerelease != 'true'
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 📥 Download release artifacts
uses: actions/download-artifact@v8
with:
name: release-artifacts
path: dist/
- name: 🚀 Trigger pkg.go.dev update
run: |
# Trigger Go module proxy to fetch the new version
curl -f "https://proxy.golang.org/github.com/M0Rf30/yap/v2/@v/${{ needs.validate.outputs.version }}.info" || echo "Module proxy update initiated"
# ===================================
# Release Notifications
# ===================================
notify:
name: 📢 Release Notifications
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [validate, goreleaser, packages]
if: always() && github.ref_type == 'tag'
steps:
- name: 📊 Determine release status
id: status
run: |
if [[ "${{ needs.goreleaser.result }}" == "success" ]]; then
echo "status=success" >> "$GITHUB_OUTPUT"
echo "message=🎉 Release ${{ needs.validate.outputs.version }} completed successfully!" >> "$GITHUB_OUTPUT"
else
echo "status=failure" >> "$GITHUB_OUTPUT"
echo "message=❌ Release ${{ needs.validate.outputs.version }} failed. Check the workflow logs." >> "$GITHUB_OUTPUT"
fi
- name: 📝 Create release summary
run: |
{
echo "## 🚀 Release Summary"
echo ""
echo "**Version:** ${{ needs.validate.outputs.version }}"
echo "**Pre-release:** ${{ needs.validate.outputs.is-prerelease }}"
echo "**Status:** ${{ steps.status.outputs.status }}"
echo ""
echo "### 📋 Job Results"
echo "- **Validation:** ${{ needs.validate.result }}"
echo "- **Binary Release:** ${{ needs.goreleaser.result }}"
echo "- **Package Publishing:** ${{ needs.packages.result }}"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
if [[ "${{ steps.status.outputs.status }}" == "success" ]]; then
{
echo "✅ Release completed successfully!"
echo ""
echo "📦 **Downloads:** https://github.com/${{ github.repository }}/releases/tag/${{ needs.validate.outputs.version }}"
echo "🐳 **Container Images:** Available on GitHub Container Registry and Docker Hub"
echo "📚 **Documentation:** https://pkg.go.dev/github.com/M0Rf30/yap/v2@${{ needs.validate.outputs.version }}"
} >> "$GITHUB_STEP_SUMMARY"
else
echo "❌ Release failed. Please check the workflow logs and try again." >> "$GITHUB_STEP_SUMMARY"
fi