diff --git a/.drone.yml b/.drone.bk.yml similarity index 100% rename from .drone.yml rename to .drone.bk.yml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..30826a9 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,19 @@ +name: validate-ci +on: + push: + branches: + - release/v* + pull_request: + types: + - opened + - reopened + - synchronize +jobs: + pr-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: ci + run: | + make ci \ No newline at end of file diff --git a/.github/workflows/tags.yaml b/.github/workflows/tags.yaml new file mode 100644 index 0000000..bd24705 --- /dev/null +++ b/.github/workflows/tags.yaml @@ -0,0 +1,53 @@ +name: Push to Master + +on: + push: + tags: + - "v*.*.*" # Matches any tag that starts with 'v' and follows semantic versioning + - "v*.*.*-ent*" + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login to Dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: CI + env: + CROSS: "true" + run: make ci + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.DOCKER_REPO || github.repository }} + tags: | + type=ref,event=tag + type=ref,event=branch + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build to Dockerhub + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64/v8 + file: package/Dockerfile + context: . + labels: ${{ steps.meta.outputs.labels }} + tags: "${{ steps.meta.outputs.tags }}" + push: true + - name: checksum + run: | + cd dist/artifacts + sha256sum ./* > sha256sum.txt + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: "dist/artifacts/*" + draft: true diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 57ccac8..f501fba 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -4,7 +4,7 @@ ARG DAPPER_HOST_ARCH ENV ARCH=${DAPPER_HOST_ARCH} RUN zypper -n update && \ - zypper -n install bash git binutils glibc-devel-static gcc vim less file tar gzip curl sed wget ca-certificates + zypper -n install bash git binutils glibc-devel-static gcc vim less file tar gzip curl sed wget ca-certificates docker ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH_arm64=arm64 GOLANG_ARCH=GOLANG_ARCH_${ARCH} \ GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash diff --git a/package/Dockerfile b/package/Dockerfile index d81ee04..d1e162a 100755 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,9 +1,11 @@ FROM registry.suse.com/bci/bci-base:15.4 +ARG TARGETPLATFORM +ENV TARGETPATH=${TARGETPLATFORM:-"."} RUN zypper -n update && \ zypper -n clean -a && \ rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/* RUN useradd --uid 1007 ack-operator ENV KUBECONFIG /home/ack-operator/.kube/config -COPY bin/ack-operator /usr/bin/ +COPY bin/${TARGETPATH}/ack-operator /usr/bin/ USER 1007 ENTRYPOINT ["ack-operator"] diff --git a/scripts/build b/scripts/build index 5c5cf01..d70728e 100755 --- a/scripts/build +++ b/scripts/build @@ -4,8 +4,22 @@ source $(dirname $0)/version cd $(dirname $0)/.. +mkdir -p dist/artifacts/ mkdir -p bin if [ "$(uname)" = "Linux" ]; then OTHER_LINKFLAGS="-extldflags -static -s" fi -CGO_ENABLED=0 go build -ldflags "$OTHER_LINKFLAGS" -o bin/ack-operator \ No newline at end of file +CGO_ENABLED=0 go build -ldflags "$OTHER_LINKFLAGS" -o bin/ack-operator + +if [ -n "$CROSS" ]; then + for platform in linux/amd64 linux/arm64; do + os="${platform%/*}" + arch="${platform#*/}" + FLAGS="$LINKFLAGS" + [ "$os" = "linux" ] && FLAGS="-extldflags -static -s $FLAGS" + echo "building $os $arch binary" + mkdir -p bin/$os/$arch + GOOS=$os GOARCH=$arch go build -ldflags "$FLAGS" -o bin/$os/$arch/ack-operator + cp bin/$os/$arch/ack-operator dist/artifacts/ack-operator-$os-$arch + done +fi diff --git a/scripts/package b/scripts/package index 4c4a707..d386ee7 100755 --- a/scripts/package +++ b/scripts/package @@ -5,10 +5,13 @@ source $(dirname $0)/version cd $(dirname $0)/.. -mkdir -p dist/artifacts -cp bin/ack-operator dist/artifacts/ack-operator-linux${SUFFIX} -for i in bin/ack-operator-*; do - if [ -e "$i" ]; then - cp $i dist/artifacts - fi -done +IMAGE=${REPO}/ack-operator:${TAG} +DOCKERFILE=package/Dockerfile +if [ -e ${DOCKERFILE}.${ARCH} ]; then + DOCKERFILE=${DOCKERFILE}.${ARCH} +fi + +docker build -f ${DOCKERFILE} -t ${IMAGE} . +echo ${REPO}/ack-operator:${VERSION} > dist/images.txt + +echo Built ${IMAGE}