Release Images #116
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Images | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 1-5' # Runs at 00:00 UTC on Mon to Friday | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: 'The release version of image' | |
| required: false | |
| default: 'latest' | |
| image_repo: | |
| description: 'Image repository for kubeblocks (e.g. ghcr.io/labring/kubeblocks)' | |
| required: false | |
| default: '' | |
| tools_image_repo: | |
| description: 'Image repository for kubeblocks-tools (e.g. ghcr.io/labring/kubeblocks-tools)' | |
| required: false | |
| default: '' | |
| datascript_image_repo: | |
| description: 'Image repository for kubeblocks-datascript (e.g. ghcr.io/labring/kubeblocks-datascript)' | |
| required: false | |
| default: '' | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: write | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_VERSION: ${{ github.ref_name }} | |
| REGISTRY: ghcr.io | |
| ORG: ${{ github.repository_owner }} | |
| jobs: | |
| release-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release-version: ${{ steps.get_release_version.outputs.release_version }} | |
| release-version-bump: ${{ steps.get_release_version.outputs.release_version_bump }} | |
| steps: | |
| - name: Get Release Version | |
| id: get_release_version | |
| run: | | |
| RELEASE_VERSION="latest" | |
| if [[ ! -z "${{ inputs.release_version }}" ]]; then | |
| RELEASE_VERSION="${{ inputs.release_version }}" | |
| elif [[ "${{ env.RELEASE_VERSION }}" == "main" ]]; then | |
| RELEASE_VERSION="latest" | |
| elif [[ ! -z "${{ env.RELEASE_VERSION }}" ]]; then | |
| RELEASE_VERSION=${{ env.RELEASE_VERSION }} | |
| fi | |
| echo release_version=$RELEASE_VERSION >> $GITHUB_OUTPUT | |
| RELEASE_VERSION_BUMP="${RELEASE_VERSION/v/}" | |
| echo release_version_bump=$RELEASE_VERSION_BUMP >> $GITHUB_OUTPUT | |
| publish-ghcr-images: | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: [ release-version ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - image: kubeblocks | |
| dockerfile: ./docker/Dockerfile | |
| context: . | |
| image_repo: ${{ inputs.image_repo != '' && inputs.image_repo || format('ghcr.io/{0}/kubeblocks', github.repository_owner) }} | |
| - image: kubeblocks-tools | |
| dockerfile: ./docker/Dockerfile-tools | |
| context: . | |
| image_repo: ${{ inputs.tools_image_repo != '' && inputs.tools_image_repo || format('ghcr.io/{0}/kubeblocks-tools', github.repository_owner) }} | |
| - image: kubeblocks-datascript | |
| dockerfile: ./docker/Dockerfile-datascript | |
| context: . | |
| image_repo: ${{ inputs.datascript_image_repo != '' && inputs.datascript_image_repo || format('ghcr.io/{0}/kubeblocks-datascript', github.repository_owner) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ matrix.image_repo }} | |
| tags: | | |
| type=raw,value=${{ needs.release-version.outputs.release-version }} | |
| type=raw,value=latest,enable=${{ needs.release-version.outputs.release-version == 'latest' }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.context }} | |
| file: ${{ matrix.dockerfile }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| sbom: false |