diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8d92892..d70a24b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,30 +31,51 @@ jobs: fetch-depth: 0 - name: Calculate new version with autotag + id: autotag run: | curl -sL https://git.io/autotag-install | sh -s -- -b "${RUNNER_TEMP}/bin" set -x version=$(${RUNNER_TEMP}/bin/autotag -n) echo "version=$version" >> $GITHUB_ENV + echo "version=${version}" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3 - - name: Release + - name: Build and push + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/planetscale/k8s-node-tagger:v${{ steps.autotag.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - set -eou pipefail - set -x + gh release create "v${version}" \ + --target main \ + --title "v${version}" \ + --generate-notes - image="ghcr.io/planetscale/k8s-node-tagger:v${version}" + # - name: Release + # run: | + # set -eou pipefail + # set -x - git reset --hard && git clean -ffdx && git pull + # image="ghcr.io/planetscale/k8s-node-tagger:v${version}" - docker buildx build \ - -t "$image" \ - --platform linux/amd64,linux/arm64 \ - --push \ - . + # git reset --hard && git clean -ffdx && git pull - gh release create "v${version}" --target main --title "v${version}" --generate-notes - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + # docker buildx build \ + # -t "$image" \ + # --platform linux/amd64,linux/arm64 \ + # --push \ + # . + + # gh release create "v${version}" --target main --title "v${version}" --generate-notes + # env: + # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/Dockerfile b/Dockerfile index 7d98019..1867120 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ # syntax=docker/dockerfile:1.9 -FROM --platform=$BUILDPLATFORM pscale.dev/wolfi-prod/go:1.23 AS builder +FROM --platform=$BUILDPLATFORM pscale.dev/wolfi-prod/go:1.23 AS deps + +ENV GOMODCACHE=/go/pkg/mod + +WORKDIR /work + +COPY go.mod go.sum ./ + +RUN go mod download + +FROM deps AS builder ARG TARGETOS ARG TARGETARCH -WORKDIR /work -COPY . /work +COPY . . ENV CGO_ENABLED=0 -RUN GOOS=${TARGETOS} GOOARCH=${TARGETARCH} go build -trimpath -v -o ./k8s-node-tagger . +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -v -o ./k8s-node-tagger . -# -- runtime image: -- +# --- runtime image ---- FROM pscale.dev/wolfi-prod/static:latest - COPY --from=builder /work/k8s-node-tagger /k8s-node-tagger - -ENTRYPOINT ["/k8s-node-tagger"] +ENTRYPOINT ["/k8s-node-tagger"] \ No newline at end of file