refactor: stop no-op reconcile writes that churn resourceVersion at s… #73
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 | |
| # Builds the operator image (and Helm charts on tags) and publishes them to the | |
| # GitHub Container Registry (ghcr.io). On pushes to main the image is published | |
| # as :latest and :sha-<sha>; on a vX.Y.Z tag it is published with semver tags. | |
| # Pull requests build the image but do not push (Dockerfile validation only). | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| permissions: {} | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| image: | |
| name: Build and push image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Clone the code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| - name: Log in to the Container registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract image metadata | |
| id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=sha,prefix=sha- | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: true | |
| sbom: true | |
| chart: | |
| name: Package and push Helm charts | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| # Keyless signing trades this OIDC token for a short-lived Fulcio | |
| # certificate: the signature is bound to this workflow's identity, so | |
| # there is no long-lived private key to store or rotate. | |
| id-token: write | |
| steps: | |
| - name: Clone the code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Helm | |
| uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 | |
| - name: Install cosign | |
| uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 | |
| - name: Log in to the Container registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login "${REGISTRY}" --username "${{ github.actor }}" --password-stdin | |
| # cosign authenticates through the Docker config, which `helm registry | |
| # login` does not write — so log in again the Docker way for the push of | |
| # the signature itself. | |
| - name: Log in to the Container registry (for cosign) | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Package, push and sign charts | |
| run: | | |
| version="${GITHUB_REF_NAME#v}" | |
| for chart in charts/valkey-operator charts/valkey-cluster; do | |
| helm package "$chart" --version "$version" --app-version "$version" | |
| done | |
| for pkg in *.tgz; do | |
| # `helm push` reports the pushed ref and its digest. Sign BY DIGEST so | |
| # the signature binds to that exact artifact and cannot be voided by | |
| # someone later moving the tag. | |
| out=$(helm push "$pkg" "oci://${REGISTRY}/${{ github.repository_owner }}/charts" 2>&1) | |
| echo "$out" | |
| ref=$(printf '%s\n' "$out" | awk '/Pushed:/{print $2}') | |
| digest=$(printf '%s\n' "$out" | awk '/Digest:/{print $2}') | |
| if [ -z "$ref" ] || [ -z "$digest" ]; then | |
| echo "could not parse ref/digest out of helm push output for $pkg" >&2 | |
| exit 1 | |
| fi | |
| cosign sign --yes "${ref%:*}@${digest}" | |
| done |