Skip to content

build and publish images #142

build and publish images

build and publish images #142

name: build and publish images
on:
# trigger testing manually
workflow_dispatch:
jobs:
build-and-publish-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get submodule version
id: version
run: |
sha=$(git submodule status -- ./PolarDB-for-PostgreSQL/ | awk '{print $1}')
pg_version=$(grep AC_INIT ./PolarDB-for-PostgreSQL/configure.ac | awk -F'[][]' '{print $4}')
pg_majorversion=$(grep AC_INIT ./PolarDB-for-PostgreSQL/configure.ac | awk -F '[][]' '{split($4, v, "."); print v[1]}')
polar_majorversion=${pg_version}
polar_minorversion=$(grep '^POLAR_MINORVERSION' ./PolarDB-for-PostgreSQL/configure.ac | cut -d '"' -f2)
echo "sha=${sha:0:8}" >> $GITHUB_OUTPUT
echo "version=${polar_majorversion}.${polar_minorversion}" >> $GITHUB_OUTPUT
echo "pg_majorversion=${pg_majorversion}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to the ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Alibaba Cloud ACR
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIBABA_CLOUD_ACR_USERNAME }}
password: ${{ secrets.ALIBABA_CLOUD_ACR_PASSWORD }}
- name: Build and push binary image
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile-binary
tags: |
polardb/polardb_pg_binary:${{ steps.version.outputs.pg_majorversion }}
ghcr.io/apsaradb/polardb_pg_binary:${{ steps.version.outputs.pg_majorversion }}
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_binary:${{ steps.version.outputs.pg_majorversion }}
platforms: linux/amd64, linux/arm64
- name: Build and push instance image
uses: docker/build-push-action@v5
with:
push: true
build-args: |
binary_image_tag=${{ steps.version.outputs.version }}.${{ steps.version.outputs.sha }}
file: Dockerfile-local-instance
tags: |
polardb/polardb_pg_local_instance:${{ steps.version.outputs.pg_majorversion }}
ghcr.io/apsaradb/polardb_pg_local_instance:${{ steps.version.outputs.pg_majorversion }}
registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_local_instance:${{ steps.version.outputs.pg_majorversion }}
platforms: linux/amd64, linux/arm64