Skip to content

Commit

Permalink
release oceanbase-ce by build-push-action
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Aug 27, 2024
1 parent d920094 commit 39ad8a7
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 109 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/release-lts-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@ jobs:
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*\.\d*-\d{18})' --only-matching)" >> $GITHUB_OUTPUT

build-and-test:
uses: ./.github/workflows/reusable-build-and-test-oceanbase-ce.yml
needs: set-version
with:
cache_key: release-lts-oceanbase-ce
version: ${{ needs.set-version.outputs.version }}

release:
uses: ./.github/workflows/reusable-release-oceanbase-ce.yml
needs: build-and-test
needs: set-version
with:
cache_key: release-lts-oceanbase-ce
version: ${{ needs.set-version.outputs.version }}
lts: true
10 changes: 1 addition & 9 deletions .github/workflows/release-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@ jobs:
id: set_version_vars
run: echo "version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*\.\d*-\d{18})' --only-matching)" >> $GITHUB_OUTPUT

build-and-test:
uses: ./.github/workflows/reusable-build-and-test-oceanbase-ce.yml
needs: set-version
with:
cache_key: release-oceanbase-ce
version: ${{ needs.set-version.outputs.version }}

release:
uses: ./.github/workflows/reusable-release-oceanbase-ce.yml
needs: build-and-test
needs: set-version
with:
cache_key: release-oceanbase-ce
version: ${{ needs.set-version.outputs.version }}
lts: false
2 changes: 2 additions & 0 deletions .github/workflows/reusable-build-and-test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
with:
cache_key: ${{ inputs.cache_key }}
version: ${{ inputs.version }}
push-images: false
push-lts-images: false

test-slim:
needs: build
Expand Down
67 changes: 64 additions & 3 deletions .github/workflows/reusable-build-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ name: build oceanbase-ce image
on:
workflow_call:
inputs:
cache_key:
required: true
type: string
version:
required: true
type: string
cache_key:
required: false
type: string
push-images:
required: false
type: boolean
push-lts-images:
required: false
type: boolean

jobs:
build-oceanbase-ce-image:
Expand All @@ -35,6 +41,29 @@ jobs:

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

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

- name: Log in to Quay io
if: ${{ inputs.push-images }}
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}

- name: Log in to Ghcr io
if: ${{ inputs.push-images }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build pre image
uses: docker/build-push-action@v6
Expand All @@ -53,13 +82,45 @@ jobs:
mkdir -p ./oceanbase-ce/share
docker run -v ./oceanbase-ce/share:/root/share oceanbase-ce-pre
- name: Set image tags
if: ${{ inputs.push-images }}
id: set_image_tags
run: |
image_tags=""
image_tags="${image_tags} ${{ env.DOCKER_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}"
image_tags="${image_tags} quay.io/${{ env.QUAY_IO_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}"
image_tags="${image_tags} ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${{ inputs.version }}"
if [[ "${{ inputs.push-lts-images }}" == "true" ]]; then
lts_version="$(echo ${{ inputs.version }} | grep -P '(\d*\.\d*\.\d*)' --only-matching)"
lts_tag="${lts_version}-lts"
image_tags="${image_tags} ${{ env.DOCKER_PUSH_BASE }}/oceanbase-ce:${lts_tag}"
image_tags="${image_tags} quay.io/${{ env.QUAY_IO_PUSH_BASE }}/oceanbase-ce:${lts_tag}"
image_tags="${image_tags} ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${lts_tag}"
fi
echo "image tags: ${image_tags}"
echo "tags=${image_tags}" >> $GITHUB_OUTPUT
- name: Build and push observer image
if: ${{ inputs.push-images }}
uses: docker/build-push-action@v6
with:
context: ./oceanbase-ce
platforms: linux/amd64,linux/arm64
file: ./oceanbase-ce/Dockerfile
push: true
tags: ${{ steps.set_image_tags.outputs.tags }}
build-args: |
VERSION=${{ inputs.version }}
- name: Build observer image
if: ${{ inputs.push-images == false }}
run: |
cd oceanbase-ce
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/amd64 -t oceanbase-ce:amd64 --load --output type=docker,dest=./oceanbase-ce-amd64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/arm64 -t oceanbase-ce:arm64 --load --output type=docker,dest=./oceanbase-ce-arm64.tar .
- name: Upload artifact
if: ${{ inputs.push-images == false }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cache_key }}
Expand Down
101 changes: 13 additions & 88 deletions .github/workflows/reusable-release-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: release oceanbase-ce image
on:
workflow_call:
inputs:
cache_key:
required: true
type: string
version:
required: true
type: string
Expand All @@ -14,88 +11,16 @@ on:
type: boolean

jobs:
release-oceanbase-ce:
runs-on: ubuntu-latest
steps:
- name: Free disk space on Ubuntu runner
uses: kfir4444/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true

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

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

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

- name: Log in to Quay io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}

- name: Log in to Ghcr io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.cache_key }}
path: /tmp

- name: Load observer images
run: |
docker load -i /tmp/oceanbase-ce-amd64.tar
rm -f /tmp/oceanbase-ce-amd64.tar
docker load -i /tmp/oceanbase-ce-arm64.tar
rm -f /tmp/oceanbase-ce-arm64.tar
- name: Publish observer images with version tag
run: |
gh_tag=ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${{ inputs.version }}
docker buildx imagetools create --dry-run --tag $gh_tag oceanbase-ce:amd64 oceanbase-ce:arm64
docker push $gh_tag
docker tag $gh_tag quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}
docker push quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}
docker tag $gh_tag ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${{ inputs.version }}
docker push ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${{ inputs.version }}
- name: Publish observer images with lts tag
if: ${{ inputs.lts }}
run: |
gh_tag=ghcr.io/${{ github.repository_owner }}/oceanbase-ce:${{ inputs.version }}
lts_version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*)' --only-matching)
lts_tag="${lts_version}-lts"
docker tag $gh_tag ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker tag $gh_tag ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:latest
docker push ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker push ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:latest
docker tag $gh_tag quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker tag $gh_tag quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:latest
docker push quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker push quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:latest
docker tag $gh_tag ghcr.io/${{ github.repository_owner }}/oceanbase-ce:$lts_tag
docker tag $gh_tag ghcr.io/${{ github.repository_owner }}/oceanbase-ce:latest
docker push ghcr.io/${{ github.repository_owner }}/oceanbase-ce:$lts_tag
docker push ghcr.io/${{ github.repository_owner }}/oceanbase-ce:latest
build-and-test:
uses: ./.github/workflows/reusable-build-and-test-oceanbase-ce.yml
with:
cache_key: release-oceanbase-ce
version: ${{ inputs.version }}

release:
uses: ./.github/workflows/reusable-build-oceanbase-ce.yml
needs: build-and-test
with:
version: ${{ inputs.version }}
push-images: true
push-lts-images: ${{ inputs.lts }}

0 comments on commit 39ad8a7

Please sign in to comment.