|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: Build server [${{ matrix.platform }}] |
| 10 | + runs-on: ${{ matrix.runs-on }} |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + - platform: amd64-linux |
| 15 | + runs-on: ubuntu-24.04 |
| 16 | + - platform: arm64-linux |
| 17 | + runs-on: ubuntu-24.04-arm |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v6 |
| 21 | + - name: Install Rust |
| 22 | + uses: CfirTsabari/actions-rs-toolchain@fcebefd2149855a4b12c9ee62208ed0f622de15b |
| 23 | + - name: Build server |
| 24 | + run: cargo build --release |
| 25 | + - name: Upload artifact |
| 26 | + uses: actions/upload-artifact@v6 |
| 27 | + with: |
| 28 | + name: ${{ matrix.platform }} |
| 29 | + path: target/release/brioche-cache-server |
| 30 | + test: |
| 31 | + name: Run tests |
| 32 | + runs-on: ubuntu-24.04 |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v6 |
| 36 | + - name: Install Rust |
| 37 | + uses: CfirTsabari/actions-rs-toolchain@fcebefd2149855a4b12c9ee62208ed0f622de15b |
| 38 | + - name: Install nextest |
| 39 | + uses: taiki-e/install-action@nextest |
| 40 | + - name: Run tests |
| 41 | + run: cargo nextest run --workspace |
| 42 | + build-and-push-image: |
| 43 | + name: Build and push image |
| 44 | + needs: [build, test] |
| 45 | + runs-on: ubuntu-24.04 |
| 46 | + permissions: |
| 47 | + contents: read |
| 48 | + packages: write |
| 49 | + attestations: write |
| 50 | + id-token: write |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v6 |
| 54 | + - name: Download artifacts |
| 55 | + uses: actions/download-artifact@v7 |
| 56 | + with: |
| 57 | + path: artifacts |
| 58 | + - name: Login to GitHub Container Registry |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + registry: ghcr.io |
| 62 | + username: ${{ github.actor }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + - name: Get Docker metadata |
| 65 | + id: meta |
| 66 | + uses: docker/metadata-action@v5 |
| 67 | + with: |
| 68 | + images: ghcr.io/${{ github.repository }} |
| 69 | + tags: type=sha,format=long |
| 70 | + - name: Set up QEMU |
| 71 | + uses: docker/setup-qemu-action@v3 |
| 72 | + - name: Set up Docker Buildx |
| 73 | + uses: docker/setup-buildx-action@v3 |
| 74 | + - name: Build and push Docker image |
| 75 | + id: push |
| 76 | + uses: docker/build-push-action@v6 |
| 77 | + with: |
| 78 | + context: . |
| 79 | + platforms: linux/amd64,linux/arm64 |
| 80 | + push: true |
| 81 | + tags: ${{ steps.meta.outputs.tags }} |
| 82 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments