-
-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move from DroneCI + VMs for platform builds + DockerHub to Github Actions + buildx + ghcr
- Loading branch information
1 parent
a3413dd
commit 4145090
Showing
8 changed files
with
358 additions
and
464 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,187 @@ | ||
name: Release | ||
name: Test & Release | ||
|
||
on: workflow_dispatch | ||
on: | ||
- push | ||
- workflow_dispatch | ||
|
||
env: | ||
IMAGE_REGISTRY: ghcr.io | ||
IMAGE_BASE_REPO: k3d-io | ||
IMAGE_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 | ||
GO_VERSION: "1.17.x" | ||
DOCKER_VERSION: "20.10" | ||
|
||
jobs: | ||
release: | ||
test-suite: | ||
name: Full Test Suite | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
# Setup | ||
- uses: actions/checkout@v2 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.17.x" | ||
go-version: "${{ env.GO_VERSION }}" | ||
- name: Setup Docker | ||
uses: docker-practice/actions-setup-docker@master | ||
with: | ||
docker_version: "20.10" | ||
docker_version: "${{ env.DOCKER_VERSION }}" | ||
- name: Setup CI Tools | ||
run: make ci-setup | ||
- name: lint | ||
# Code Check | ||
- name: Run Static Analysis | ||
run: make lint | ||
- name: test | ||
# Tests | ||
- name: Run Go Tests | ||
run: make test | ||
- name: e2e | ||
- name: Run E2E Tests | ||
timeout-minutes: 20 | ||
run: make e2e | ||
- name: build | ||
# Builds | ||
- name: Test Platform Builds | ||
run: make build-cross | ||
- name: Test Helper Image Builds | ||
run: make build-helper-images | ||
|
||
release: | ||
name: Build & Release | ||
# Only run on tags | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
# Setup | ||
- uses: actions/checkout@v2 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "${{ env.GO_VERSION }}" | ||
- name: Setup CI Tools | ||
run: make ci-setup | ||
# Go Build | ||
- name: Build k3d Binary | ||
run: make build-cross | ||
# Container Image Setup | ||
- name: Setup Docker | ||
uses: docker-practice/actions-setup-docker@master | ||
with: | ||
docker_version: "${{ env.DOCKER_VERSION }}" | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
# Gather Docker Metadata | ||
- name: Docker Metadata k3d-binary | ||
id: meta-k3d-binary | ||
env: | ||
IMAGE_ID: k3d | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
bake-target: docker-metadata-${{ env.IMAGE_ID }} | ||
tags: | | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
- name: Docker Metadata k3d-dind | ||
id: meta-k3d-dind | ||
env: | ||
IMAGE_ID: k3d | ||
IMAGE_SUFFIX: "-dind" | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
bake-target: docker-metadata-${{ env.IMAGE_ID }}${{ env.IMAGE_SUFFIX }} | ||
tags: | | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
flavor: | | ||
suffix=${{ env.IMAGE_SUFFIX }} | ||
- name: Docker Metadata k3d-proxy | ||
id: meta-k3d-proxy | ||
env: | ||
IMAGE_ID: k3d-proxy | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
bake-target: docker-metadata-${{ env.IMAGE_ID }} | ||
tags: | | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
- name: Docker Metadata k3d-tools | ||
id: meta-k3d-tools | ||
env: | ||
IMAGE_ID: k3d-tools | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
bake-target: docker-metadata-${{ env.IMAGE_ID }} | ||
tags: | | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
- name: Merge Metadata Bake Definitions | ||
run: | | ||
INPUT=(${{ steps.meta-k3d-binary.outputs.bake-file }} ${{ steps.meta-k3d-dind.outputs.bake-file }} ${{ steps.meta-k3d-proxy.outputs.bake-file }} ${{ steps.meta-k3d-tools.outputs.bake-file }}) | ||
OUT_FILE=./bake-metadata.json | ||
OUT_FILE_TMP=./bake-metadata-tmp.json | ||
cat << EOF > $OUT_FILE | ||
{ | ||
"target": {} | ||
} | ||
EOF | ||
for file in "${INPUT[@]}"; do | ||
cat $OUT_FILE > $OUT_FILE_TMP | ||
jq -s '.[0] * .[1]' $OUT_FILE_TMP $file > $OUT_FILE | ||
done | ||
rm "$OUT_FILE_TMP" | ||
# Build and Push container images | ||
- name: Build Images | ||
uses: docker/[email protected] | ||
with: | ||
files: | | ||
./docker-bake.hcl | ||
./bake-metadata.json | ||
targets: release | ||
push: false | ||
- name: Wait for tests to succeed | ||
uses: lewagon/[email protected] | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: "Full Test Suite" | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-interval: 20 | ||
- name: Push Images | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/[email protected] | ||
with: | ||
files: | | ||
./docker-bake.hcl | ||
./bake-metadata.json | ||
targets: release | ||
push: true |
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
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
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,40 @@ | ||
// release group | ||
group "release" { | ||
targets = ["binary", "dind", "proxy", "tools"] | ||
} | ||
|
||
// filled by GitHub Actions | ||
target "docker-metadata-k3d" {} | ||
target "docker-metadata-k3d-dind" {} | ||
target "docker-metadata-k3d-proxy" {} | ||
target "docker-metadata-k3d-tools" {} | ||
|
||
// default options for creating a release | ||
target "default-release-options" { | ||
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"] | ||
} | ||
|
||
target "binary" { | ||
inherits = ["default-release-options", "docker-metadata-k3d"] | ||
dockerfile = "Dockerfile" | ||
context = "." | ||
target = "binary-only" | ||
} | ||
|
||
target "dind" { | ||
inherits = ["docker-metadata-k3d-dind"] // dind does not inherit defaults, as dind base image is not available for armv7 | ||
platforms = ["linux/amd64", "linux/arm64"] | ||
dockerfile = "Dockerfile" | ||
context = "." | ||
target = "dind" | ||
} | ||
|
||
target "proxy" { | ||
inherits = ["default-release-options", "docker-metadata-k3d-proxy"] | ||
context = "proxy/" | ||
} | ||
|
||
target "tools" { | ||
inherits = ["default-release-options", "docker-metadata-k3d-tools"] | ||
context = "tools/" | ||
} |
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
FROM nginx:1.19-alpine | ||
# TODO:_ consider switching to https://github.com/abtreece/confd to not maintain a custom fork anymore | ||
ARG CONFD_REPO=iwilltry42/confd | ||
ARG CONFD_VERSION=0.17.0-rc.0 | ||
ARG OS=linux | ||
ARG ARCH=amd64 | ||
RUN echo "Building for '${OS}/${ARCH}'..." \ | ||
&& mkdir -p /etc/confd \ | ||
&& wget "https://github.com/${CONFD_REPO}/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-${OS}-${ARCH}" -O /usr/bin/confd \ | ||
&& chmod +x /usr/bin/confd | ||
|
||
ARG OS | ||
ARG ARCH | ||
|
||
ENV OS=${OS} | ||
ENV ARCH=${ARCH} | ||
COPY install-confd.sh /scripts/install-confd.sh | ||
RUN mkdir -p /etc/confd \ | ||
&& /scripts/install-confd.sh | ||
|
||
COPY templates /etc/confd/templates/ | ||
COPY conf.d /etc/confd/conf.d/ | ||
COPY nginx-proxy /usr/bin/ | ||
|
||
ENTRYPOINT nginx-proxy | ||
ENTRYPOINT nginx-proxy |
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,49 @@ | ||
#!/bin/sh | ||
|
||
# initArch discovers the architecture for this system. | ||
initArch() { | ||
if [ -z $ARCH ]; then | ||
ARCH=$(uname -m) | ||
case $ARCH in | ||
armv5*) ARCH="armv5";; | ||
armv6*) ARCH="armv6";; | ||
armv7*) ARCH="arm";; | ||
aarch64) ARCH="arm64";; | ||
x86) ARCH="386";; | ||
x86_64) ARCH="amd64";; | ||
i686) ARCH="386";; | ||
i386) ARCH="386";; | ||
esac | ||
fi | ||
} | ||
|
||
# initOS discovers the operating system for this system. | ||
initOS() { | ||
if [ -z $OS ]; then | ||
OS=$(uname|tr '[:upper:]' '[:lower:]') | ||
|
||
case "$OS" in | ||
# Minimalist GNU for Windows | ||
mingw*) OS='windows';; | ||
esac | ||
fi | ||
} | ||
|
||
|
||
install_confd() { | ||
echo "Installing confd for $OS/$ARCH..." | ||
CONFD_REPO=iwilltry42/confd | ||
CONFD_VERSION=0.17.0-rc.0 | ||
curl -sSfL "https://github.com/${CONFD_REPO}/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-${OS}-${ARCH}" -o ./confd | ||
chmod +x ./confd | ||
mv ./confd /usr/local/bin/confd | ||
} | ||
|
||
|
||
# | ||
# MAIN | ||
# | ||
|
||
initOS | ||
initArch | ||
install_confd |
Oops, something went wrong.