Publish release artifacts (docker images, helm chart) to GHCR #4
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: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| 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 | |
| - name: Get tag name | |
| id: vars | |
| run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT | |
| - name: Set Release Date | |
| run: | | |
| echo "BUILT_AT=$(date --rfc-3339=date)" >> ${GITHUB_ENV} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Login against Docker Hub | |
| - name: Login to DockerHub Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # Login against GitHub Container Registry | |
| - 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 }} | |
| # Extract metadata for zookeeper Apache image | |
| - name: Extract Docker metadata for zookeeper Apache | |
| if: ${{ startsWith(github.ref, 'refs/tags/zk') }} | |
| 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-${{ steps.vars.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 | |
| if: ${{ startsWith(github.ref, 'refs/tags/zk') }} | |
| 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: ${{ startsWith(github.ref, 'refs/tags/zk') }} | |
| # Extract metadata for zookeeper image | |
| - name: Extract Docker metadata for zookeeper | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| 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-${{ steps.vars.outputs.tag }} | |
| labels: | | |
| org.opencontainers.image.description=Apache Zookeeper image build with java-21 | |
| - name: Build and push zookeeper image | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| 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/') && !startsWith(github.ref, 'refs/tags/zk') }} | |
| # Extract metadata for zookeeper-operator image | |
| - name: Extract Docker metadata for zookeeper-operator | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| 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 | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| 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=${{ env.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/') && !startsWith(github.ref, 'refs/tags/zk') }} | |
| # Update Helm Chart version | |
| - name: Update Chart.yaml version | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| run: | | |
| sed -i "s/^version:.*/version: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml | |
| sed -i "s/^appVersion:.*/appVersion: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml | |
| sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ steps.vars.outputs.tag }}/" charts/zookeeper-operator/values.yaml | |
| # Push Helm Chart to GitHub Container Registry | |
| - name: Push Helm Chart to GHCR | |
| if: ${{ !startsWith(github.ref, 'refs/tags/zk') }} | |
| uses: appany/[email protected] | |
| with: | |
| name: zookeeper-operator | |
| repository: ${{ github.repository_owner }}/helm-charts | |
| tag: ${{ steps.vars.outputs.tag }} | |
| path: charts/zookeeper-operator | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| registry_username: ${{ github.actor }} | |
| registry_password: ${{ secrets.GITHUB_TOKEN }} | |
| update_dependencies: 'true' |