|
7 | 7 | paths:
|
8 | 8 | - ".github/workflows/controller.yml"
|
9 | 9 | - "operator/**"
|
10 |
| - |
| 10 | + |
11 | 11 | jobs:
|
12 |
| - build-images: |
| 12 | + build: |
| 13 | + continue-on-error: true |
| 14 | + |
13 | 15 | strategy:
|
14 |
| - fail-fast: false |
15 | 16 | matrix:
|
16 | 17 | include:
|
17 |
| - - context: operator |
18 |
| - file: operator/Dockerfile |
19 |
| - endpoint: demeter-run/ext-cardano-dbsync-serverless |
| 18 | + - release_for: Linux-x86_64 |
| 19 | + build_on: ubuntu-22.04 |
| 20 | + target: x86_64-unknown-linux-gnu |
| 21 | + args: "--locked --release" |
20 | 22 |
|
21 |
| - continue-on-error: true |
| 23 | + - release_for: Linux-arm64 |
| 24 | + build_on: ubuntu-22.04-arm |
| 25 | + target: "aarch64-unknown-linux-gnu" |
| 26 | + args: "--locked --release" |
| 27 | + |
| 28 | + runs-on: ${{ matrix.build_on }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: checkout repository |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - uses: Swatinem/rust-cache@v2 |
| 35 | + with: |
| 36 | + shared-key: "release" |
| 37 | + |
| 38 | + - name: Install stable toolchain |
| 39 | + uses: actions-rs/toolchain@v1 |
| 40 | + with: |
| 41 | + toolchain: stable |
| 42 | + |
| 43 | + - name: Run cargo build |
| 44 | + uses: actions-rs/cargo@v1 |
| 45 | + with: |
| 46 | + command: build |
| 47 | + args: --target ${{ matrix.target }} ${{ matrix.args }} |
| 48 | + |
| 49 | + - name: rename binaries |
| 50 | + run: | |
| 51 | + mv target/${{ matrix.target }}/release/controller${{ matrix.ext }} controller-${{ matrix.release_for }}${{ matrix.ext }} |
| 52 | +
|
| 53 | + - name: upload artifacts |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: binaries-${{ matrix.release_for }} |
| 57 | + path: controller-${{ matrix.release_for }}${{ matrix.ext }} |
| 58 | + |
| 59 | + docker: |
22 | 60 | runs-on: ubuntu-latest
|
| 61 | + needs: [build] |
| 62 | + |
| 63 | + permissions: |
| 64 | + contents: read |
| 65 | + packages: write |
| 66 | + |
23 | 67 | steps:
|
24 |
| - |
| 68 | + - name: Checkout repository |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Set up Docker Buildx |
| 72 | + uses: docker/setup-buildx-action@v3 |
25 | 73 |
|
26 |
| - - name: Login to GitHub Container Registry |
27 |
| - uses: docker/login-action@v1 |
| 74 | + - name: Login to DockerHub |
| 75 | + uses: docker/login-action@v3 |
28 | 76 | with:
|
29 | 77 | registry: ghcr.io
|
30 | 78 | username: ${{ github.actor }}
|
31 | 79 | password: ${{ secrets.GITHUB_TOKEN }}
|
32 | 80 |
|
| 81 | + - name: Download artifacts |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + pattern: binaries-* |
| 85 | + merge-multiple: true |
| 86 | + path: .github/image/bin |
| 87 | + |
| 88 | + # we need to rename the artifact so that the name matches |
| 89 | + # the value that Docker uses for TARGET_ARCH to keep the |
| 90 | + # Dockerfile simple |
| 91 | + - name: Rename artifacts |
| 92 | + run: |+ |
| 93 | + mv .github/image/bin/controller-Linux-x86_64 .github/image/bin/controller-Linux-amd64 |
| 94 | +
|
33 | 95 | - name: Build and push
|
34 |
| - uses: docker/build-push-action@v2 |
| 96 | + uses: docker/build-push-action@v5 |
35 | 97 | with:
|
36 |
| - context: ${{ matrix.context }} |
37 |
| - file: ${{ matrix.file }} |
38 |
| - platforms: linux/amd64 |
| 98 | + context: .github/image |
| 99 | + platforms: linux/arm64,linux/amd64 |
39 | 100 | push: true
|
40 |
| - tags: ghcr.io/${{ matrix.endpoint }},ghcr.io/${{ matrix.endpoint }}:${{ github.sha }} |
| 101 | + tags: ghcr.io/demeter-run/ext-cardano-dbsync-serverless,ghcr.io/ext-cardano-dbsync-serverless:${{ github.sha }} |
0 commit comments