Publish release artifacts (docker images, helm chart) to GHCR #8
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # GitHub Container Registry | |
| GHCR_REGISTRY: ghcr.io | |
| # github.repository as <account>/<repo> | |
| GHCR_IMAGE_NAME: ${{ github.repository }} | |
| # Docker Hub image names | |
| DOCKERHUB_ZK_IMAGE: adobe/zookeeper | |
| DOCKERHUB_OPERATOR_IMAGE: adobe/zookeeper-operator | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| tag: ${{ steps.vars.outputs.tag }} | |
| built_at: ${{ steps.date.outputs.built_at }} | |
| steps: | |
| - name: Get tag name | |
| id: vars | |
| run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT | |
| - name: Set Release Date | |
| id: date | |
| run: | | |
| echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT | |
| operator-test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go 1.25 | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: 1.25 | |
| id: go | |
| - name: Set up Go for root | |
| run: | | |
| sudo ln -sf `which go` `sudo which go` || true | |
| sudo go version | |
| - name: get go version | |
| run: go version | |
| - name: Gofmt and License checks | |
| run: make check | |
| - name: unit tests | |
| run: make test | |
| build-zookeeper-apache: | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| if: ${{ startsWith(github.ref, 'refs/tags/zk') }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - 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 Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata for zookeeper Apache | |
| id: meta-zk-apache | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.DOCKERHUB_ZK_IMAGE }} | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper | |
| tags: | | |
| type=raw,value=3.8.4-apache-${{ needs.prepare.outputs.tag }} | |
| labels: | | |
| org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21 | |
| - name: Build and push zookeeper Apache image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker/zookeeper-image | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta-zk-apache.outputs.tags }} | |
| labels: ${{ steps.meta-zk-apache.outputs.labels }} | |
| annotations: ${{ steps.meta-zk-apache.outputs.annotations }} | |
| push: true | |
| build-zookeeper: | |
| runs-on: ubuntu-latest | |
| needs: [prepare, operator-test] | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - 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 Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata for zookeeper | |
| id: meta-zk | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.DOCKERHUB_ZK_IMAGE }} | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper | |
| tags: | | |
| type=raw,value=3.8.4-${{ needs.prepare.outputs.tag }} | |
| labels: | | |
| org.opencontainers.image.description=Apache Zookeeper image build with java-21 | |
| - name: Build and push zookeeper image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta-zk.outputs.tags }} | |
| labels: ${{ steps.meta-zk.outputs.labels }} | |
| annotations: ${{ steps.meta-zk.outputs.annotations }} | |
| push: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| build-operator: | |
| runs-on: ubuntu-latest | |
| needs: [prepare, operator-test] | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - 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 Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata for zookeeper-operator | |
| id: meta-operator | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.DOCKERHUB_OPERATOR_IMAGE }} | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| labels: | | |
| org.opencontainers.image.description=Zookeeper Operator for Kubernetes | |
| - name: Build and push zookeeper-operator image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| build-args: | | |
| VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }} | |
| BUILT_AT=${{ needs.prepare.outputs.built_at }} | |
| GIT_SHA=${{ github.sha }} | |
| tags: ${{ steps.meta-operator.outputs.tags }} | |
| labels: ${{ steps.meta-operator.outputs.labels }} | |
| annotations: ${{ steps.meta-operator.outputs.annotations }} | |
| push: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| release-helm: | |
| runs-on: ubuntu-latest | |
| needs: [prepare, build-zookeeper, build-operator] | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Update Chart.yaml version | |
| run: | | |
| sed -i "s/^version:.*/version: \"${{ needs.prepare.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml | |
| sed -i "s/^appVersion:.*/appVersion: \"${{ needs.prepare.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml | |
| sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ needs.prepare.outputs.tag }}/" charts/zookeeper-operator/values.yaml | |
| - name: Push Helm Chart to GHCR | |
| uses: appany/[email protected] | |
| with: | |
| name: zookeeper-operator | |
| repository: ${{ github.repository_owner }}/helm-charts | |
| tag: ${{ needs.prepare.outputs.tag }} | |
| path: charts/zookeeper-operator | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| registry_username: ${{ github.actor }} | |
| registry_password: ${{ secrets.GITHUB_TOKEN }} | |
| update_dependencies: 'true' |