Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
ci(release): tag the image only after it boots (#851)
Yudhi Armyndharis3106f9fbc6f4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 0b7db4efb..f0b8c71bb 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -207,7 +207,7 @@ jobs:# a matching container image, and a runtime boot check on both architectures (boot-smoke runs the# published image on amd64 + arm64). Trades a few minutes of buildx/boot latency for release# safety.- needs: [lint, test, test-postgres, dashboard, build, docker, boot-smoke]+ needs: [lint, test, test-postgres, dashboard, build, docker, boot-smoke, promote]steps:- uses: actions/checkout@v7with:@@ -271,6 +271,16 @@ jobs:username: ${{ github.actor }}password: ${{ secrets.GITHUB_TOKEN }}+ # Publish under a throwaway staging tag ONLY. The release tags (X.Y.Z, X.Y, latest) are+ # applied by the `promote` job, after boot-smoke has actually started the image on both+ # architectures. Publishing them here would make a broken image pullable before the test that+ # catches it has run — which is exactly how a non-starting image reached `latest` in 0.10.3.+ - name: Resolve staging ref+ id: staging+ env:+ REPO: ${{ github.repository }}+ run: echo "ref=ghcr.io/${REPO,,}:smoke-${{ github.run_id }}" >> "$GITHUB_OUTPUT"+- name: Extract metadataid: metauses: docker/metadata-action@v6@@ -281,13 +291,13 @@ jobs:type=semver,pattern={{major}}.{{minor}}type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}- - name: Build and push+ - name: Build and push (staging tag only)uses: docker/build-push-action@v7with:context: .push: trueplatforms: ${{ env.DOCKER_PLATFORMS }}- tags: ${{ steps.meta.outputs.tags }}+ tags: ${{ steps.staging.outputs.ref }}labels: ${{ steps.meta.outputs.labels }}# provenance is generated by default (build-push-action v7); pin it explicitly and opt into# an SBOM attestation so each release image carries an in-toto SLSA provenance + SBOM pair,@@ -321,15 +331,15 @@ jobs:username: ${{ github.actor }}password: ${{ secrets.GITHUB_TOKEN }}- - name: Resolve published image ref+ - name: Resolve staging image refid: image- # metadata-action publishes the {{version}} tag (e.g. 0.8.17) from the v-prefixed git tag, so- # strip the leading "v" to match it. ${REPO,,} lowercases github.repository — GHCR normalizes- # the repo name to lowercase on push, and `docker run` rejects a mixed-case reference, so the- # pull target must be lowercase too (this repo is rmyndharis/OpenWA).+ # The image under test carries only the staging tag at this point — the release tags are+ # applied by `promote`, after this job passes. ${REPO,,} lowercases github.repository: GHCR+ # normalizes the repo name to lowercase on push and `docker run` rejects a mixed-case+ # reference, so the pull target must be lowercase too (this repo is rmyndharis/OpenWA).env:REPO: ${{ github.repository }}- run: echo "ref=ghcr.io/${REPO,,}:${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"+ run: echo "ref=ghcr.io/${REPO,,}:smoke-${{ github.run_id }}" >> "$GITHUB_OUTPUT"- name: Boot + liveness check on each architectureenv:@@ -339,7 +349,10 @@ jobs:for platform in linux/amd64 linux/arm64; doecho "::group::boot-smoke $platform"docker rm -f openwa-smoke >/dev/null 2>&1 || true- if ! docker run --rm --platform "$platform" -d -p 2785:2785 --name openwa-smoke "$IMAGE" >/dev/null; then+ # Deliberately NOT --rm: a container that exits on its own is auto-removed by --rm, so+ # `docker logs` below finds nothing and the failure reports no cause. The explicit+ # `docker rm -f` at the end of each iteration handles cleanup instead.+ if ! docker run --platform "$platform" -d -p 2785:2785 --name openwa-smoke "$IMAGE" >/dev/null; thenecho "FAIL: $platform — could not start container (image pull/run error)"exit_code=1echo "::endgroup::"@@ -362,3 +375,83 @@ jobs:echo "::endgroup::"doneexit "$exit_code"++ # Applies the release tags (X.Y.Z, X.Y, latest) to the image boot-smoke just proved can start.+ # `imagetools create` re-points tags at the existing manifest list without rebuilding, so the+ # promoted image is bit-identical to the one tested, and its provenance and SBOM attestations+ # travel with it. If boot-smoke fails, this job never runs and the release tags never appear.+ promote:+ name: Promote image to release tags+ runs-on: ubuntu-latest+ permissions:+ packages: write+ needs: [boot-smoke]+ steps:+ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v4++ - name: Login to GitHub Container Registry+ uses: docker/login-action@v4+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Extract metadata+ id: meta+ uses: docker/metadata-action@v6+ with:+ images: ghcr.io/${{ github.repository }}+ tags: |+ type=semver,pattern={{version}}+ type=semver,pattern={{major}}.{{minor}}+ type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}++ - name: Tag the smoke-tested image with the release tags+ env:+ REPO: ${{ github.repository }}+ TAGS: ${{ steps.meta.outputs.tags }}+ run: |+ set -euo pipefail+ staging="ghcr.io/${REPO,,}:smoke-${{ github.run_id }}"+ # metadata-action emits one tag per line. A here-string rather than a pipe, so the loop+ # runs in this shell and `set -e` actually aborts the step on a failed promotion instead+ # of the pipeline swallowing it.+ promoted=0+ while IFS= read -r tag; do+ [ -n "$tag" ] || continue+ echo "promoting -> $tag"+ docker buildx imagetools create --tag "$tag" "$staging"+ promoted=$((promoted + 1))+ done <<< "$TAGS"+ if [ "$promoted" -eq 0 ]; then+ echo "::error::no release tags were produced by metadata-action — nothing was promoted"+ exit 1+ fi+ echo "promoted $promoted tag(s)"++ - name: Verify the release tag resolves and is multi-arch+ env:+ REPO: ${{ github.repository }}+ run: |+ ref="ghcr.io/${REPO,,}:${GITHUB_REF#refs/tags/v}"+ docker buildx imagetools inspect "$ref" | tee /tmp/inspect.txt+ for want in linux/amd64 linux/arm64; do+ grep -q "$want" /tmp/inspect.txt || { echo "MISSING PLATFORM: $want"; exit 1; }+ done++ # Best-effort: the staging tag has served its purpose. Leaving it would accumulate one stray+ # tag per release. A failure here must not fail the release — the tags are already promoted.+ - name: Remove the staging tag+ continue-on-error: true+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: |+ version_id=$(gh api "/users/${{ github.repository_owner }}/packages/container/openwa/versions" \+ --jq ".[] | select(.metadata.container.tags[]? == \"smoke-${{ github.run_id }}\") | .id" | head -1)+ if [ -n "$version_id" ]; then+ gh api -X DELETE "/users/${{ github.repository_owner }}/packages/container/openwa/versions/$version_id" \+ && echo "removed staging tag version $version_id"+ else+ echo "staging tag not found (already cleaned up)"+ fidiff --git a/CHANGELOG.md b/CHANGELOG.mdindex d2db86670..93f8063be 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Changed++- **A release image is only tagged after it has been proven to start.** The release workflow+ published `X.Y.Z`, `X.Y` and `latest` in the same step that built the image, and only then ran+ the boot smoke test — so an image that could not start was already pullable by the time the+ test that catches it failed, which is exactly what happened with `0.10.3`. The build now+ publishes a throwaway `smoke-<run-id>` tag, the smoke test boots that on both architectures,+ and a new promote step re-points the release tags at the identical manifest (no rebuild, so+ provenance and SBOM attestations carry over) only once it passes. The GitHub Release depends+ on the promote step, and the staging tag is cleaned up afterwards.+- The smoke test no longer starts containers with `--rm`, so a container that exits on its own+ survives long enough for `docker logs` to report why. The `0.10.3` failure reported+ "No such container" instead of the actual error.+## [0.10.4] - 2026-07-21> ⚠️ **Use this release, not `0.10.3`.** The `0.10.3` container image does not start: its