-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
923dd1f
commit 8e30e28
Showing
3 changed files
with
176 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' | ||
|
||
jobs: | ||
release: | ||
permissions: | ||
contents: write # for release | ||
packages: write # for publishing docker images | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@v2 | ||
with: | ||
egress-policy: audit | ||
- name: Retrieve build information | ||
id: build | ||
run: | | ||
VERSION="${GITHUB_REF#refs/tags/}" | ||
echo "Releasing ${VERSION}" | ||
echo "VERSION=${VERSION}" >> $GITHUB_ENV | ||
- name: Log in to the Container registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: https://ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build bootstrap provider image | ||
run: make BOOTSTRAP_IMG_TAG=${{ env.VERSION }} docker-build-bootstrap | ||
|
||
- name: Build controlplane provider image | ||
run: make CONTROLPLANE_IMG_TAG=${{ env.VERSION }} docker-build-controlplane | ||
|
||
- name: Publish bootstrap provider image | ||
run: | | ||
make BOOTSTRAP_IMG_TAG=${{ env.VERSION }} docker-push-bootstrap | ||
make BOOTSTRAP_IMG_TAG=${{ env.VERSION }} docker-manifest-bootstrap | ||
- name: Publish controlplane provider image | ||
run: | | ||
make CONTROLPLANE_IMG_TAG=${{ env.VERSION }} docker-push-controlplane | ||
make CONTROLPLANE_IMG_TAG=${{ env.VERSION }} docker-manifest-controlplane | ||
- name: Build manifests | ||
run: | | ||
make release | ||
sed -i "s,ghcr.io/canonical/cluster-api-k8s/bootstrap-controller:latest,ghcr.io/canonical/cluster-api-k8s/bootstrap-controller:${{ env.VERSION }}," out/bootstrap-components.yaml | ||
sed -i "s,ghcr.io/canonical/cluster-api-k8s/controlplane-controller:latest,ghcr.io/canonical/cluster-api-k8s/controlplane-controller:${{ env.VERSION }}," out/control-plane-components.yaml | ||
- name: Create GitHub Release | ||
uses: softprops/[email protected] | ||
with: | ||
name: 'Release ${{ env.VERSION }}' | ||
tag_name: ${{ env.VERSION }} | ||
files: | | ||
out/bootstrap-components.yaml | ||
out/control-plane-components.yaml | ||
out/metadata.yaml | ||
generate_release_notes: true | ||
draft: ${{ contains(env.VERSION, 'rc') }} | ||
prerelease: ${{ contains(env.VERSION, 'rc') }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Build the manager binary | ||
# Run this with docker build --build-arg builder_image=<golang:x.y.z> | ||
ARG builder_image | ||
|
||
# Build architecture | ||
ARG ARCH | ||
|
||
# Ignore Hadolint rule "Always tag the version of an image explicitly." | ||
# It's an invalid finding since the image is explicitly set in the Makefile. | ||
# https://github.com/hadolint/hadolint/wiki/DL3006 | ||
# hadolint ignore=DL3006 | ||
FROM ${builder_image} as builder | ||
WORKDIR /workspace | ||
|
||
# Run this with docker build --build-arg goproxy=$(go env GOPROXY) to override the goproxy | ||
ARG goproxy=off | ||
# Run this with docker build --build-arg package=./controlplane/kubeadm or --build-arg package=./bootstrap/kubeadm | ||
ENV GOPROXY=$goproxy | ||
|
||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
|
||
# Cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
# Copy the sources | ||
COPY ./ ./ | ||
|
||
# Build | ||
ARG package=. | ||
ARG ARCH | ||
ARG ldflags | ||
|
||
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \ | ||
go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \ | ||
-o manager ${package} | ||
|
||
# Production image | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies | ||
USER 65532 | ||
ENTRYPOINT ["/manager"] |
This file contains 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