diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2e04b8c..36ea67b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -204,57 +204,3 @@ jobs: with: name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }} path: ./_artifacts/logs - - publish: - name: publish - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') - timeout-minutes: 100 - needs: - - e2e - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Publish image for tags - uses: docker/build-push-action@v6 - with: - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - if: startsWith(github.ref, 'refs/tags/v') - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fb5c4a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: e2e + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +env: + GO_VERSION: "1.22.3" + K8S_VERSION: "v1.30.0" + KIND_VERSION: "v0.22.0" + KIND_CLUSTER_NAME: "kindnet" + REGISTRY: ghcr.io + IMAGE_NAME: aojea/kindnetd + +jobs: + + publish: + name: publish + runs-on: ubuntu-latest + timeout-minutes: 100 + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index f9180ff..405b7f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,24 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG GOARCH="amd64" # STEP 1: Build kindnetd binary -FROM golang:1.22 AS builder +FROM --platform=$BUILDPLATFORM golang:1.22 AS builder # golang envs -ARG GOARCH="amd64" ARG CNI_VERSION="v1.5.0" -ARG GOOS=linux ENV CGO_ENABLED=0 -ENV GO111MODULE="on" -ENV GOPROXY=https://proxy.golang.org # copy in sources WORKDIR /src COPY . . # build -RUN CGO_ENABLED=0 go build -o /go/bin/kindnetd ./cmd/kindnetd +ARG TARGETARCH +RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /go/bin/kindnetd ./cmd/kindnetd # Install CNI plugins RUN echo "Installing CNI binaries ..." \ - && export CNI_TARBALL="${CNI_VERSION}/cni-plugins-linux-${GOARCH}-${CNI_VERSION}.tgz" \ + && export CNI_TARBALL="${CNI_VERSION}/cni-plugins-linux-${TARGETARCH}-${CNI_VERSION}.tgz" \ && export CNI_URL="https://github.com/containernetworking/plugins/releases/download/${CNI_TARBALL}" \ && curl -sSL --retry 5 --output /tmp/cni.tgz "${CNI_URL}" \ && mkdir -p /opt/cni/bin \