diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 92c0ad2..d6c02fe 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,18 +1,16 @@ -name: Build and Push Docker Image +name: Release on: push: - branches: - - main tags: - 'v*' permissions: - contents: read + contents: write packages: write jobs: - build-and-push: + release: runs-on: ubuntu-latest steps: - name: Checkout code @@ -28,24 +26,41 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/kubeorch/core - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,prefix= + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - name: Build and push + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ghcr.io/kubeorch/core:latest + ghcr.io/kubeorch/core:${{ steps.version.outputs.VERSION }} + labels: | + org.opencontainers.image.title=KubeOrch Core + org.opencontainers.image.version=${{ steps.version.outputs.VERSION }} + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.VERSION }} + name: ${{ steps.version.outputs.VERSION }} + generate_release_notes: true + body: | + ## Docker Image + + ```bash + docker pull ghcr.io/kubeorch/core:${{ steps.version.outputs.VERSION }} + ``` + + Run with `orchcli`: + ```bash + orchcli init && orchcli start -d + ``` diff --git a/Dockerfile b/Dockerfile index f9f2eae..c7a23dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,6 @@ # Stage 1: Builder FROM golang:1.25-alpine AS builder -# Build args for multi-platform support -ARG TARGETOS=linux -ARG TARGETARCH=amd64 - # Install git and ca-certificates for fetching dependencies RUN apk add --no-cache git ca-certificates @@ -22,8 +18,8 @@ RUN go mod download # Copy source code COPY . . -# Build the application for the target platform -RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \ +# Build the application +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ -ldflags="-w -s" \ -o kubeorch-core \ .