Skip to content

Commit

Permalink
add reusable release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Aug 21, 2024
1 parent de61334 commit 4524a88
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 38 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/reusable-build-and-test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
cache_key:
required: true
type: string
image_name:
required: true
type: string
version:
required: true
type: string
Expand All @@ -18,16 +15,13 @@ jobs:
uses: ./.github/workflows/reusable-build-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
version: ${{ inputs.version }}

test-slim:
needs: build
uses: ./.github/workflows/reusable-test-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
image_file: ${{ inputs.image_name }}-amd64.tar
mode: slim
port: 1234
test_password: 123456
Expand All @@ -40,8 +34,6 @@ jobs:
uses: ./.github/workflows/reusable-test-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
image_file: ${{ inputs.image_name }}-amd64.tar
cluster_name: github-action
mode: mini
port: 1234
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/reusable-build-oblogproxy-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
cache_key:
required: true
type: string
image_name:
required: true
type: string
version:
required: false
type: string
Expand Down Expand Up @@ -42,11 +39,11 @@ jobs:
- name: Build oblogproxy-ce image
run: |
cd oblogproxy-ce
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/amd64 -t ${{ inputs.image_name }} --load --output type=docker,dest=./${{ inputs.image_name }}-amd64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/arm64 -t ${{ inputs.image_name }} --load --output type=docker,dest=./${{ inputs.image_name }}-arm64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/amd64 -t oblogproxy-ce-amd64 --load --output type=docker,dest=./oblogproxy-ce-amd64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/arm64 -t oblogproxy-ce-arm64 --load --output type=docker,dest=./oblogproxy-ce-arm64.tar .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cache_key }}
path: oblogproxy-ce/${{ inputs.image_name }}-**.tar
path: oblogproxy-ce/oblogproxy-ce-**.tar
9 changes: 3 additions & 6 deletions .github/workflows/reusable-build-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
cache_key:
required: true
type: string
image_name:
required: true
type: string
version:
required: true
type: string
Expand Down Expand Up @@ -59,11 +56,11 @@ jobs:
- name: Build observer image
run: |
cd oceanbase-ce
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/amd64 -t ${{ inputs.image_name }} --load --output type=docker,dest=./${{ inputs.image_name }}-amd64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/arm64 -t ${{ inputs.image_name }} --load --output type=docker,dest=./${{ inputs.image_name }}-arm64.tar .
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
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cache_key }}
path: oceanbase-ce/${{ inputs.image_name }}-**.tar
path: oceanbase-ce/oceanbase-ce-**.tar
94 changes: 94 additions & 0 deletions .github/workflows/reusable-release-oceanbase-ce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: release oceanbase-ce image

on:
workflow_call:
inputs:
cache_key:
required: true
type: string
version:
required: true
type: string
lts:
required: true
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: 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: |
docker buildx imagetools create --tag oceanbase-ce ${{ inputs.image_name }}-amd64 ${{ inputs.image_name }}-arm64
docker tag oceanbase-ce ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}
docker push ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:${{ inputs.version }}
docker tag oceanbase-ce 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 oceanbase-ce 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: |
lts_version=$(echo $tagName | grep -P '(\d*\.\d*\.\d*)' --only-matching)
lts_tag="${lts_version}-lts"
docker tag oceanbase-ce ${{ vars.DOCKER_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker tag oceanbase-ce ${{ 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 oceanbase-ce quay.io/${{ vars.QUAY_IO_PUSH_BASE }}/oceanbase-ce:$lts_tag
docker tag oceanbase-ce 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 oceanbase-ce ghcr.io/${{ github.repository_owner }}/oceanbase-ce:$lts_tag
docker tag oceanbase-ce 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
12 changes: 4 additions & 8 deletions .github/workflows/reusable-test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ on:
cache_key:
required: true
type: string
image_name:
required: true
type: string
image_file:
required: true
type: string
mode:
required: true
type: string
Expand Down Expand Up @@ -60,12 +54,14 @@ jobs:
path: /tmp

- name: Load Docker image
run: docker load -i /tmp/${{ inputs.image_file }}
run: |
docker load -i /tmp/oceanbase-ce-amd64.tar
rm -f /tmp/oceanbase-ce-amd64.tar
- name: Start Docker container
uses: oceanbase/setup-oceanbase-ce@v1
with:
image_name: ${{ inputs.image_name }}
image_name: oceanbase-ce-amd64
container_name: oceanbase-ce
mode: ${{ inputs.mode }}
cluster_name: ${{ inputs.cluster_name }}
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/test-oblogproxy-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ jobs:
build-oceanbase-ce:
uses: ./.github/workflows/reusable-build-oceanbase-ce.yml
with:
cache_key: test-oblogproxy-ce_oceanbase-ce
image_name: oceanbase-ce
cache_key: test-oblogproxy-ce-oceanbase-ce
version: 4.2.1.8-108000022024072217

build-oblogproxy-ce:
uses: ./.github/workflows/reusable-build-oblogproxy-ce.yml
with:
cache_key: test-oblogproxy-ce_oblogproxy-ce
image_name: oblogproxy-ce
cache_key: test-oblogproxy-ce-oblogproxy-ce

test-oblogproxy-ce:
runs-on: ubuntu-latest
Expand All @@ -43,19 +41,20 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: test-oblogproxy-ce_**
pattern: test-oblogproxy-ce-**
path: /tmp

- name: Load Docker image
run: |
docker load -i /tmp/test-oblogproxy-ce_oceanbase-ce/oceanbase-ce-amd64.tar
docker load -i /tmp/test-oblogproxy-ce_oblogproxy-ce/oblogproxy-ce-amd64.tar
sudo rm -rf /tmp/*
docker load -i /tmp/test-oblogproxy-ce-oceanbase-ce/oceanbase-ce-amd64.tar
rm -f /tmp/test-oblogproxy-ce-oceanbase-ce/oceanbase-ce-amd64.tar
docker load -i /tmp/test-oblogproxy-ce-oblogproxy-ce/oblogproxy-ce-amd64.tar
rm -f /tmp/test-oblogproxy-ce-oblogproxy-ce/oblogproxy-ce-amd64.tar
- name: Start oceanbase-ce container
uses: oceanbase/setup-oceanbase-ce@v1
with:
image_name: oceanbase-ce
image_name: oceanbase-ce-amd64
container_name: oceanbase-ce
sql_port: 12881
rpc_port: 12882
Expand All @@ -64,7 +63,7 @@ jobs:
tenant_root_password: 654321

- name: Start oblogproxy-ce container
run: docker run --name oblogproxy-ce -e OB_SYS_USERNAME=root -e OB_SYS_PASSWORD=123456 -p 12983:2983 -d oblogproxy-ce
run: docker run --name oblogproxy-ce -e OB_SYS_USERNAME=root -e OB_SYS_PASSWORD=123456 -p 12983:2983 -d oblogproxy-ce-amd64

- name: Set container IP
id: set_container_ip
Expand Down

0 comments on commit 4524a88

Please sign in to comment.