|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +env: |
| 9 | + REGISTRY: docker.io |
| 10 | + IMAGE_NAME: cbaugus/rust_loadtest |
| 11 | + |
| 12 | +jobs: |
| 13 | + # ── 1. Lint ──────────────────────────────────────────────────────────────── |
| 14 | + lint: |
| 15 | + name: Lint (rustfmt & clippy) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 10 |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install Rust toolchain |
| 22 | + uses: dtolnay/rust-toolchain@stable |
| 23 | + with: |
| 24 | + components: rustfmt, clippy |
| 25 | + |
| 26 | + - name: Cache Rust dependencies |
| 27 | + uses: Swatinem/rust-cache@v2 |
| 28 | + with: |
| 29 | + shared-key: lint |
| 30 | + |
| 31 | + - name: Check formatting |
| 32 | + run: cargo fmt --all --check |
| 33 | + |
| 34 | + - name: Run clippy |
| 35 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 36 | + |
| 37 | + # ── 2. Test ──────────────────────────────────────────────────────────────── |
| 38 | + test: |
| 39 | + name: Test Suite |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 15 |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Install Rust toolchain |
| 46 | + uses: dtolnay/rust-toolchain@stable |
| 47 | + |
| 48 | + - name: Cache Rust dependencies |
| 49 | + uses: Swatinem/rust-cache@v2 |
| 50 | + with: |
| 51 | + shared-key: test |
| 52 | + |
| 53 | + - name: Run unit tests |
| 54 | + run: cargo test --lib --all-features --verbose -- --test-threads=1 |
| 55 | + timeout-minutes: 10 |
| 56 | + |
| 57 | + - name: Run integration tests |
| 58 | + run: cargo test --test '*' --all-features --verbose -- --test-threads=1 |
| 59 | + timeout-minutes: 10 |
| 60 | + |
| 61 | + # ── 3. Build & publish Docker images ────────────────────────────────────── |
| 62 | + build-and-release: |
| 63 | + name: Build, Push & Release |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: [lint, test] |
| 66 | + timeout-minutes: 30 |
| 67 | + permissions: |
| 68 | + contents: write # needed to create GitHub releases |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@v4 |
| 72 | + |
| 73 | + # Strip the leading 'v' to get a bare semver (e.g. v1.5.3 → 1.5.3) |
| 74 | + - name: Derive version strings |
| 75 | + id: version |
| 76 | + run: | |
| 77 | + TAG="${{ github.ref_name }}" |
| 78 | + SEMVER="${TAG#v}" |
| 79 | + echo "tag=${TAG}" >> $GITHUB_OUTPUT |
| 80 | + echo "semver=${SEMVER}" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + - name: Set up QEMU |
| 83 | + uses: docker/setup-qemu-action@v3 |
| 84 | + |
| 85 | + - name: Set up Docker Buildx |
| 86 | + uses: docker/setup-buildx-action@v3 |
| 87 | + |
| 88 | + - name: Log in to Docker Hub |
| 89 | + uses: docker/login-action@v3 |
| 90 | + with: |
| 91 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 93 | + |
| 94 | + # ── Standard image ────────────────────────────────────────────────── |
| 95 | + - name: Build standard image (load for SBOM) |
| 96 | + uses: docker/build-push-action@v5 |
| 97 | + with: |
| 98 | + context: . |
| 99 | + file: ./Dockerfile |
| 100 | + platforms: linux/amd64 |
| 101 | + tags: ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} |
| 102 | + push: false |
| 103 | + load: true |
| 104 | + cache-from: type=gha |
| 105 | + cache-to: type=gha,mode=max |
| 106 | + |
| 107 | + # ── Chainguard image ───────────────────────────────────────────────── |
| 108 | + - name: Build Chainguard image (load for SBOM) |
| 109 | + uses: docker/build-push-action@v5 |
| 110 | + with: |
| 111 | + context: . |
| 112 | + file: ./Dockerfile.chainguard |
| 113 | + platforms: linux/amd64 |
| 114 | + tags: ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}-Chainguard |
| 115 | + push: false |
| 116 | + load: true |
| 117 | + cache-from: type=gha |
| 118 | + |
| 119 | + # ── SBOMs ───────────────────────────────────────────────────────────── |
| 120 | + - name: Install Syft |
| 121 | + run: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin |
| 122 | + |
| 123 | + - name: Generate SBOM — standard |
| 124 | + run: | |
| 125 | + syft "docker:${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}" \ |
| 126 | + -o cyclonedx-json > sbom-standard.cyclonedx.json |
| 127 | +
|
| 128 | + - name: Generate SBOM — Chainguard |
| 129 | + run: | |
| 130 | + syft "docker:${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}-Chainguard" \ |
| 131 | + -o cyclonedx-json > sbom-chainguard.cyclonedx.json |
| 132 | +
|
| 133 | + # ── Push standard: version tag + latest ─────────────────────────────── |
| 134 | + - name: Push standard image |
| 135 | + uses: docker/build-push-action@v5 |
| 136 | + with: |
| 137 | + context: . |
| 138 | + file: ./Dockerfile |
| 139 | + platforms: linux/amd64 |
| 140 | + tags: | |
| 141 | + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} |
| 142 | + ${{ env.IMAGE_NAME }}:latest |
| 143 | + provenance: true |
| 144 | + push: true |
| 145 | + cache-from: type=gha |
| 146 | + |
| 147 | + # ── Push Chainguard: version tag + latest-Chainguard ───────────────── |
| 148 | + - name: Push Chainguard image |
| 149 | + uses: docker/build-push-action@v5 |
| 150 | + with: |
| 151 | + context: . |
| 152 | + file: ./Dockerfile.chainguard |
| 153 | + platforms: linux/amd64 |
| 154 | + tags: | |
| 155 | + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}-Chainguard |
| 156 | + ${{ env.IMAGE_NAME }}:latest-Chainguard |
| 157 | + provenance: true |
| 158 | + push: true |
| 159 | + cache-from: type=gha |
| 160 | + |
| 161 | + # ── Update Docker Hub repository description ────────────────────────── |
| 162 | + - name: Update Docker Hub description |
| 163 | + uses: peter-evans/dockerhub-description@v4 |
| 164 | + with: |
| 165 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 166 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 167 | + repository: ${{ env.IMAGE_NAME }} |
| 168 | + readme-filepath: ./DOCKER_HUB_OVERVIEW.md |
| 169 | + |
| 170 | + # ── GitHub Release ──────────────────────────────────────────────────── |
| 171 | + - name: Create GitHub Release |
| 172 | + uses: softprops/action-gh-release@v2 |
| 173 | + with: |
| 174 | + tag_name: ${{ steps.version.outputs.tag }} |
| 175 | + name: ${{ steps.version.outputs.tag }} |
| 176 | + generate_release_notes: true |
| 177 | + files: | |
| 178 | + sbom-standard.cyclonedx.json |
| 179 | + sbom-chainguard.cyclonedx.json |
| 180 | + body: | |
| 181 | + ## Docker images |
| 182 | +
|
| 183 | + | Variant | Pull command | |
| 184 | + |---------|-------------| |
| 185 | + | Standard (Ubuntu) | `docker pull ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}` | |
| 186 | + | Chainguard (minimal) | `docker pull ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}-Chainguard` | |
| 187 | +
|
| 188 | + `latest` and `latest-Chainguard` are also updated to this release. |
| 189 | +
|
| 190 | + ## SBOMs |
| 191 | + CycloneDX SBOMs for both images are attached to this release. |
0 commit comments