|
| 1 | +name: Release Verification |
| 2 | + |
| 3 | +# Fires after release-please publishes a GitHub Release (which also pushes a |
| 4 | +# `v*` tag and triggers docker-publish.yml). This workflow is the last gate |
| 5 | +# in the chain and provides two guarantees: |
| 6 | +# |
| 7 | +# 1. smoke-test: the *published* image (not a locally-built one) actually |
| 8 | +# starts cleanly using the same setup.sh + docker-compose flow that |
| 9 | +# self-hosters follow. If this fails, the release is auto-marked as a |
| 10 | +# pre-release so it stops being advertised as the "Latest" release. |
| 11 | +# |
| 12 | +# 2. bundle: attach a self-hoster bundle (docker-compose.production.yml |
| 13 | +# with the image tag pinned + setup.sh) to the GitHub Release so users |
| 14 | +# can `curl -L .../releases/download/v1.4.0/reqcore-1.4.0.tar.gz` and |
| 15 | +# get a deterministic, version-locked install. |
| 16 | + |
| 17 | +on: |
| 18 | + release: |
| 19 | + types: [published] |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + tag: |
| 23 | + description: "Release tag to verify (e.g. v1.4.0)" |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + |
| 30 | +concurrency: |
| 31 | + group: release-verification-${{ github.event.release.tag_name || inputs.tag }} |
| 32 | + cancel-in-progress: false |
| 33 | + |
| 34 | +jobs: |
| 35 | + smoke-test: |
| 36 | + name: Smoke-test published image |
| 37 | + runs-on: ubuntu-latest |
| 38 | + timeout-minutes: 35 |
| 39 | + steps: |
| 40 | + - name: Resolve release tag |
| 41 | + id: tag |
| 42 | + run: | |
| 43 | + set -euo pipefail |
| 44 | + tag="${{ github.event.release.tag_name || inputs.tag }}" |
| 45 | + version="${tag#v}" |
| 46 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 47 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + - name: Checkout release tag |
| 50 | + uses: actions/checkout@v6 |
| 51 | + with: |
| 52 | + ref: ${{ steps.tag.outputs.tag }} |
| 53 | + |
| 54 | + - name: Pin compose file to the released image tag |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + sed -i \ |
| 58 | + "s|ghcr.io/reqcore-inc/reqcore:latest|ghcr.io/reqcore-inc/reqcore:${{ steps.tag.outputs.version }}|" \ |
| 59 | + docker-compose.production.yml |
| 60 | + grep "ghcr.io/reqcore-inc/reqcore" docker-compose.production.yml |
| 61 | +
|
| 62 | + - name: Wait for the published image to be available on GHCR |
| 63 | + run: | |
| 64 | + set -euo pipefail |
| 65 | + # docker-publish.yml is triggered by the same tag push, so it may |
| 66 | + # still be running when this job starts. Poll for up to 20 minutes. |
| 67 | + for i in $(seq 60); do |
| 68 | + if docker manifest inspect "ghcr.io/reqcore-inc/reqcore:${{ steps.tag.outputs.version }}" > /dev/null 2>&1; then |
| 69 | + echo "✅ Image is available" |
| 70 | + exit 0 |
| 71 | + fi |
| 72 | + echo " attempt $i/60 — image not yet published, waiting 20s..." |
| 73 | + sleep 20 |
| 74 | + done |
| 75 | + echo "❌ Image ghcr.io/reqcore-inc/reqcore:${{ steps.tag.outputs.version }} never appeared" |
| 76 | + exit 1 |
| 77 | +
|
| 78 | + - name: Generate .env via setup.sh |
| 79 | + run: | |
| 80 | + chmod +x ./setup.sh |
| 81 | + ./setup.sh |
| 82 | +
|
| 83 | + - name: Start full stack against the published image |
| 84 | + run: docker compose -f docker-compose.production.yml up -d |
| 85 | + |
| 86 | + - name: Wait for app to be reachable |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + for i in $(seq 60); do |
| 90 | + if curl -fs http://localhost:3000 > /dev/null 2>&1; then |
| 91 | + echo "✅ App reachable" |
| 92 | + exit 0 |
| 93 | + fi |
| 94 | + sleep 3 |
| 95 | + done |
| 96 | + echo "❌ App did not become reachable" |
| 97 | + docker compose -f docker-compose.production.yml logs app --tail=200 |
| 98 | + exit 1 |
| 99 | +
|
| 100 | + - name: Assert migrations + S3 bucket ready |
| 101 | + run: | |
| 102 | + set -euo pipefail |
| 103 | + # Startup messages can land slightly after the HTTP port opens, so |
| 104 | + # poll instead of one-shot grepping to avoid flaky failures. |
| 105 | + for i in $(seq 40); do |
| 106 | + logs="$(docker compose -f docker-compose.production.yml logs app || true)" |
| 107 | + if grep -q "Database migrations applied successfully" <<<"$logs" \ |
| 108 | + && grep -q 'S3 bucket "reqcore" is ready' <<<"$logs"; then |
| 109 | + echo "✅ Migrations + S3 ready messages found (attempt $i)" |
| 110 | + exit 0 |
| 111 | + fi |
| 112 | + sleep 3 |
| 113 | + done |
| 114 | + echo "❌ Required startup messages missing after polling" |
| 115 | + docker compose -f docker-compose.production.yml logs app |
| 116 | + exit 1 |
| 117 | +
|
| 118 | + - name: Demote release to pre-release on failure |
| 119 | + if: failure() && github.event_name == 'release' |
| 120 | + env: |
| 121 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + run: | |
| 123 | + gh release edit "${{ steps.tag.outputs.tag }}" --prerelease --latest=false |
| 124 | + gh release view "${{ steps.tag.outputs.tag }}" --json isPrerelease,isLatest |
| 125 | +
|
| 126 | + bundle: |
| 127 | + name: Attach self-hoster bundle |
| 128 | + needs: smoke-test |
| 129 | + runs-on: ubuntu-latest |
| 130 | + steps: |
| 131 | + - name: Resolve release tag |
| 132 | + id: tag |
| 133 | + run: | |
| 134 | + set -euo pipefail |
| 135 | + tag="${{ github.event.release.tag_name || inputs.tag }}" |
| 136 | + version="${tag#v}" |
| 137 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 138 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 139 | +
|
| 140 | + - name: Checkout release tag |
| 141 | + uses: actions/checkout@v6 |
| 142 | + with: |
| 143 | + ref: ${{ steps.tag.outputs.tag }} |
| 144 | + |
| 145 | + - name: Build version-pinned bundle |
| 146 | + run: | |
| 147 | + set -euo pipefail |
| 148 | + mkdir -p "bundle/reqcore-${{ steps.tag.outputs.version }}" |
| 149 | + cp setup.sh "bundle/reqcore-${{ steps.tag.outputs.version }}/" |
| 150 | + cp SELF-HOSTING.md "bundle/reqcore-${{ steps.tag.outputs.version }}/" |
| 151 | + # Pin the compose file to the exact released image tag so users |
| 152 | + # who download the bundle get a deterministic install. |
| 153 | + sed \ |
| 154 | + "s|ghcr.io/reqcore-inc/reqcore:latest|ghcr.io/reqcore-inc/reqcore:${{ steps.tag.outputs.version }}|" \ |
| 155 | + docker-compose.production.yml \ |
| 156 | + > "bundle/reqcore-${{ steps.tag.outputs.version }}/docker-compose.production.yml" |
| 157 | +
|
| 158 | + cat > "bundle/reqcore-${{ steps.tag.outputs.version }}/INSTALL.txt" <<EOF |
| 159 | + Reqcore ${{ steps.tag.outputs.tag }} — Self-Hoster Bundle |
| 160 | +
|
| 161 | + 1. ./setup.sh |
| 162 | + 2. docker compose -f docker-compose.production.yml up -d |
| 163 | + 3. Open http://localhost:3000 |
| 164 | +
|
| 165 | + The image tag in docker-compose.production.yml is pinned to |
| 166 | + ${{ steps.tag.outputs.version }}. To upgrade later, download the |
| 167 | + newer release bundle and re-run docker compose up -d. |
| 168 | +
|
| 169 | + Full guide: SELF-HOSTING.md |
| 170 | + EOF |
| 171 | +
|
| 172 | + tar -czf "reqcore-${{ steps.tag.outputs.version }}.tar.gz" -C bundle "reqcore-${{ steps.tag.outputs.version }}" |
| 173 | + sha256sum "reqcore-${{ steps.tag.outputs.version }}.tar.gz" > "reqcore-${{ steps.tag.outputs.version }}.tar.gz.sha256" |
| 174 | +
|
| 175 | + - name: Attach bundle to the GitHub Release |
| 176 | + env: |
| 177 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 178 | + run: | |
| 179 | + gh release upload "${{ steps.tag.outputs.tag }}" \ |
| 180 | + "reqcore-${{ steps.tag.outputs.version }}.tar.gz" \ |
| 181 | + "reqcore-${{ steps.tag.outputs.version }}.tar.gz.sha256" \ |
| 182 | + --clobber |
0 commit comments