Skip to content

Commit

Permalink
Actions for building and releasing manifests (#107)
Browse files Browse the repository at this point in the history
* chore: workflows for building and release
  • Loading branch information
powerfooI authored Nov 29, 2023
1 parent a362dad commit 02bdbce
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 24 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build ob-operator

on:
push:
branches:
- '*_dev'

env:
GO_VERSION: "1.20"

jobs:
build-images:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: go mod vendor
run: go mod vendor

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build Docker images
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: false
1 change: 1 addition & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- 2.0.x_dev
- 2.x_dev

permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: release helm chart
name: release helm charts

on:
on:
push:
branches:
- 'master'
- '*release'
- 'helm-chart'
tags:
- '2.[0-9]+.[0-9]+'
- 'chart-2.[0-9]+.[0-9]+'

jobs:
release:
release-chart:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -22,6 +22,8 @@ jobs:
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.1.0
uses: helm/chart-releaser-action@v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
mark_as_latest: false
43 changes: 43 additions & 0 deletions .github/workflows/release-obagent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: release obagent

on:
push:
tags:
- "obagent-*"

env:
tagName: ${{ github.ref_name }}

jobs:
release-obagent:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set Version variables
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*-\d*)' --only-matching)" >> $GITHUB_OUTPUT

- name: Build and push obagent w/o cache
uses: docker/build-push-action@v2
with:
context: ./distribution/obagent
platforms: linux/amd64,linux/arm64
file: ./distribution/obagent/Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/obagent:${{ steps.set_version_vars.outputs.version }}
build-args: |
VERSION=${{ steps.set_version_vars.outputs.version }}
43 changes: 43 additions & 0 deletions .github/workflows/release-obconfigserver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: release obconfigserver

on:
push:
tags:
- "obconfigserver-*"

env:
tagName: ${{ github.ref_name }}

jobs:
release-obconfigserver:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set Version variables
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*-\d*)' --only-matching)" >> $GITHUB_OUTPUT

- name: Build and push obconfigserver w/o cache
uses: docker/build-push-action@v2
with:
context: ./distribution/ob-configserver
platforms: linux/amd64,linux/arm64
file: ./distribution/ob-configserver/Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/obconfigserver:${{ steps.set_version_vars.outputs.version }}
build-args: |
VERSION=${{ steps.set_version_vars.outputs.version }}
43 changes: 43 additions & 0 deletions .github/workflows/release-obproxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: release obproxy

on:
push:
tags:
- "obproxy-*"

env:
tagName: ${{ github.ref_name }}

jobs:
release-obproxy:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set Version variables
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*\.\d*-\d*)' --only-matching)" >> $GITHUB_OUTPUT

- name: Build and push obproxy w/o cache
uses: docker/build-push-action@v2
with:
context: ./distribution/obproxy
platforms: linux/amd64,linux/arm64
file: ./distribution/obproxy/Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/obproxy:${{ steps.set_version_vars.outputs.version }}
build-args: |
VERSION=${{ steps.set_version_vars.outputs.version }}
43 changes: 43 additions & 0 deletions .github/workflows/release-observer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: release observer

on:
push:
tags:
- "observer-*"

env:
tagName: ${{ github.ref_name }}

jobs:
release-observer:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set Version variables
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*\.\d*-\d{18})' --only-matching)" >> $GITHUB_OUTPUT

- name: Build and push observer w/o cache
uses: docker/build-push-action@v2
with:
context: ./distribution/oceanbase
platforms: linux/amd64,linux/arm64
file: ./distribution/oceanbase/Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-cloud-native:${{ steps.set_version_vars.outputs.version }}
build-args: |
VERSION=${{ steps.set_version_vars.outputs.version }}
47 changes: 47 additions & 0 deletions .github/workflows/release-operator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: release operator

on:
push:
tags:
- '2.[0-9]+.[0-9]+'

jobs:
release-operator:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and push manifests w/ cache
uses: docker/build-push-action@v2
if: ${{ vars.ENABLE_DOCKER_CACHE }}
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/ob-operator:${{ github.ref_name }}
cache-from: type=registry,ref=${{ vars.DOCKER_PUSH_BASE }}/ob-operator:buildcache
cache-to: type=registry,ref=${{ vars.DOCKER_PUSH_BASE }}/ob-operator:buildcache,mode=max

- name: Create and push manifests w/o cache
uses: docker/build-push-action@v2
if: ${{ !vars.ENABLE_DOCKER_CACHE }}
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/ob-operator:${{ github.ref_name }}
4 changes: 2 additions & 2 deletions distribution/ob-configserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM openanolis/anolisos:8.8
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ARG VERSION
ARG ARCH=x86_64
RUN yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/${ARCH}/ob-configserver-${VERSION}.el8.${ARCH}.rpm
ARG TARGETPLATFORM
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/ob-configserver-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/ob-configserver-${VERSION}.el8.aarch64.rpm ; fi
ADD config.yaml.template /home/admin/ob-configserver/conf/
ADD start.sh /home/admin/ob-configserver
WORKDIR /home/admin/ob-configserver
Expand Down
3 changes: 2 additions & 1 deletion distribution/ob-configserver/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
docker build -t $1:$2 --build-arg VERSION=$2 --build-arg ARCH=$3 .
# @Params TARGETPLATFORM linux/amd64 or linux/arm64
docker build -t $1:$2 --build-arg VERSION=$2 --build-arg TARGETPLATFORM=$3 .
4 changes: 2 additions & 2 deletions distribution/obagent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM openanolis/anolisos:8.8
ARG VERSION
ARG ARCH=x86_64
ARG TARGETPLATFORM
WORKDIR /home/admin/obagent
RUN yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/${ARCH}/obagent-${VERSION}.el8.${ARCH}.rpm
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/obagent-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/obagent-${VERSION}.el8.aarch64.rpm ; fi
ADD replace_properties.sh /home/admin/obagent
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Expand Down
3 changes: 2 additions & 1 deletion distribution/obagent/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
docker build -t $1:$2 --build-arg VERSION=$2 --build-arg ARCH=$3 .
# @Params TARGETPLATFORM linux/amd64 or linux/arm64
docker build -t $1:$2 --build-arg VERSION=$2 --build-arg TARGETPLATFORM=$3 .
6 changes: 3 additions & 3 deletions distribution/obproxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ FROM openanolis/anolisos:8.8
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ARG VERSION
ARG RELEASE
ARG ARCH=x86_64
ARG TARGETPLATFORM
WORKDIR /home/admin
RUN useradd -m admin
RUN rpm -ivh https://mirrors.aliyun.com/oceanbase/community/stable/el/8/${ARCH}/obproxy-ce-${VERSION}-${RELEASE}.el8.${ARCH}.rpm
RUN mv /home/admin/obproxy-${VERSION} /home/admin/obproxy
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then rpm -ivh https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/obproxy-ce-${VERSION}.el8.x86_64.rpm ; else rpm -ivh https://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/obproxy-ce-${VERSION}.el8.aarch64.rpm ; fi
RUN mv /home/admin/obproxy-* /home/admin/obproxy
RUN chown -R admin:admin /home/admin/obproxy
ADD start.sh /home/admin

Expand Down
4 changes: 3 additions & 1 deletion distribution/obproxy/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
docker build -t $1:$2-$3 --build-arg VERSION=$2 --build-arg RELEASE=$3 --build-arg ARCH=$4 .
# @Params TARGETPLATFORM linux/amd64 or linux/arm64
# VERSION: x.y.z-r e.g. 4.2.1-11 which merge old VERSION and RELEASE
docker build -t $1:$2 --build-arg VERSION=$2 --build-arg TARGETPLATFORM=$3 .
8 changes: 5 additions & 3 deletions distribution/oceanbase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ RUN GO11MODULE=ON CGO_ENABLED=0 GOOS=linux go build -a -o oceanbase-helper main.

FROM openanolis/anolisos:8.8
ARG VERSION
ARG ARCH=x86_64
ARG TARGETPLATFORM
RUN echo TARGET_PLATFORM is ${TARGETPLATFORM}
WORKDIR /home/admin/oceanbase
RUN mkdir -p /home/admin/oceanbase/bin
COPY --from=builder /workspace/oceanbase-helper /home/admin/oceanbase/bin
RUN yum -y install python27
RUN pip2 install mysql-connector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
RUN yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/${ARCH}/oceanbase-ce-libs-${VERSION}.el8.${ARCH}.rpm
RUN yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/${ARCH}/oceanbase-ce-${VERSION}.el8.${ARCH}.rpm
# support docker platform linux/amd64 and linux/arm64, mapping platform to x86_64 or aarch64
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-libs-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/oceanbase-ce-libs-${VERSION}.el8.aarch64.rpm ; fi
RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]] ; then yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-${VERSION}.el8.x86_64.rpm ; else yum install -y http://mirrors.aliyun.com/oceanbase/community/stable/el/8/aarch64/oceanbase-ce-${VERSION}.el8.aarch64.rpm ; fi
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV LD_LIBRARY_PATH /home/admin/oceanbase/lib
4 changes: 2 additions & 2 deletions distribution/oceanbase/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

docker build -t $1:$2 --build-arg GOPROXY=${GOPROXY} --build-arg VERSION=$2 --build-arg ARCH=$3 .
# @Params TARGETPLATFORM linux/amd64 or linux/arm64
docker build -t $1:$2 --build-arg GOPROXY=${GOPROXY} --build-arg VERSION=$2 --build-arg TARGETPLATFORM=$3 .
2 changes: 1 addition & 1 deletion doc/development/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ob-operator requires [go 1.20 or above](https://go.dev/doc/install) to build, yo
ob-operator uses [make](https://www.gnu.org/software/make/) for a variety of build and test actions, it's need to be installed before you go.

3. kubebuilder
ob-operator uses kubebuilder as operator framework, before you dive into the code, it's highly recommended to read [kubebuilder books](https://book.kubebuilder.io)
ob-operator uses kubebuilder as operator framework, before you dive into the code, it's highly recommended to read [kubebuilder books](https://book.kubebuilder.io).

## build ob-operator

Expand Down

0 comments on commit 02bdbce

Please sign in to comment.