Skip to content

Commit

Permalink
feat: move to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
orangedeng committed Oct 18, 2024
1 parent 11f7682 commit bfb0664
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 10 deletions.
File renamed without changes.
19 changes: 19 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/workflows/tags.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 15 additions & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
17 changes: 10 additions & 7 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit bfb0664

Please sign in to comment.