diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54eb47d..2a2625a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,14 @@ -name: Versioned images +name: Publish images on: push: + branches: [main] tags: ['v*.*.*'] + workflow_dispatch: permissions: contents: read +concurrency: + group: publish-${{ github.sha }} + cancel-in-progress: false jobs: verify: uses: ./.github/workflows/ci.yml @@ -25,21 +30,42 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Image tags + id: tags + env: + IMAGE: ghcr.io/${{ github.repository }}-${{ matrix.target }} + shell: bash + run: | + image="${IMAGE,,}" + echo "image=$image" >> "$GITHUB_OUTPUT" + { + echo 'tags<> "$GITHUB_OUTPUT" - uses: docker/build-push-action@v6 + id: build with: context: . file: infrastructure/docker/Dockerfile target: ${{ matrix.target }} platforms: linux/amd64,linux/arm64 push: true - tags: | - ghcr.io/stephanterning/tendly-${{ matrix.target }}:${{ github.ref_name }} - ghcr.io/stephanterning/tendly-${{ matrix.target }}:sha-${{ github.sha }} + tags: ${{ steps.tags.outputs.tags }} labels: | - org.opencontainers.image.source=https://github.com/stephanterning/tendly + org.opencontainers.image.source=https://github.com/${{ github.repository }} org.opencontainers.image.licenses=AGPL-3.0-or-later org.opencontainers.image.revision=${{ github.sha }} + - name: Record published digest + env: + IMAGE: ${{ steps.tags.outputs.image }} + DIGEST: ${{ steps.build.outputs.digest }} + run: printf 'Image `%s@%s` (commit `%s`)\n' "$IMAGE" "$DIGEST" "$GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY" release: + if: startsWith(github.ref, 'refs/tags/') needs: images runs-on: ubuntu-latest permissions: diff --git a/docs/operations.md b/docs/operations.md index bb09469..ea855b8 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -35,12 +35,20 @@ CI/development installations. ## Upgrades and release images CI validates contracts, lint/types/build, focused tests, real PostgreSQL migrations, -and Compose build/restart checks. Version tags `vX.Y.Z` run these checks again before -publishing amd64/arm64 API/worker/web images to GHCR. No release images have been -published by Stage 1. Never reuse a released tag; record image digests in release notes. +and Compose build/restart checks. The Publish images workflow runs these checks +before publishing amd64/arm64 +API/worker/web images to GHCR on main pushes, version tags `vX.Y.Z`, or manual +workflow runs. Every build publishes `sha-` tags; version-tag +builds also publish their version and create a GitHub release. All three images +must use the same source revision. Publishing never triggers a server deployment. +Confirm all three images finished publishing before deploying, and pin their +individual digests for reproducible deployments. Package visibility must be public +for installations to pull without registry credentials. Never reuse a released tag; +record image digests in release notes. Registry owners should restrict package/tag overwrite permissions. -For a future published version, set TENDLY_VERSION to its full tag, pull the images, +For a published version, set TENDLY_VERSION to its full version or `sha-` tag, +pull the images, and run Compose without building. There are no automatic upgrades. Before upgrading, back up the database, attachment files and required secrets. Recreate the one-shot migration service for each deployment so a previous exited container is not mistaken