feat: add cluster options, DNS settings, refacator.. #40
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: Build, Push & Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to build (leave empty for automatic versioning)' | |
| required: false | |
| type: string | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}} | |
| - name: Calculate version | |
| id: version | |
| run: | | |
| if [[ -n "${{ github.event.inputs.version }}" ]]; then | |
| # Use manually specified version | |
| VERSION="${{ github.event.inputs.version }}" | |
| elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
| # If this is a tag, use the tag version | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} | |
| else | |
| # Try to get the latest tag, if none exists, start from v0.0.0 | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| LATEST_TAG=${LATEST_TAG#v} | |
| # Get the commit count from the beginning of the repository | |
| # This ensures we always have a valid number even with no tags | |
| COMMITS_SINCE_TAG=$(git rev-list --count HEAD) | |
| # Split version into major and minor | |
| MAJOR=$(echo $LATEST_TAG | cut -d. -f1) | |
| MINOR=$(echo $LATEST_TAG | cut -d. -f2) | |
| # If we couldn't parse the version properly, default to 0.0 | |
| if [[ -z "$MAJOR" ]] || [[ -z "$MINOR" ]]; then | |
| MAJOR=0 | |
| MINOR=0 | |
| fi | |
| # Calculate new version | |
| VERSION="${MAJOR}.${COMMITS_SINCE_TAG}" | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} | |
| ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| provenance: false | |
| sbom: false | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for release notes file | |
| id: notes | |
| run: | | |
| if [[ -f RELEASE_NOTES.md ]]; then | |
| echo "has_notes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_notes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create GitHub Release (with custom notes) | |
| if: steps.notes.outputs.has_notes == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: RELEASE_NOTES.md | |
| generate_release_notes: false | |
| - name: Create GitHub Release (auto-generated notes) | |
| if: steps.notes.outputs.has_notes == 'false' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true |