From a93aa85c021c4a08fc66aba54948e0767b27b191 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 23 Jul 2024 05:23:05 -0400 Subject: [PATCH] Build base binaries --- .github/workflows/build.yaml | 84 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3e6da39..1a2f216 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,27 +1,36 @@ -name: Build Docker images +name: Build + on: push: - branches: [main] + branches: + - main permissions: contents: read packages: write jobs: - build-server: + docker: runs-on: ubuntu-latest + strategy: + matrix: + include: + - image: orbit-server + dockerfile: ./Dockerfile.server + - image: orbit-cli + dockerfile: ./Dockerfile.cli steps: - uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Docker meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: | - ghcr.io/m1guelpf/orbit-server + ghcr.io/m1guelpf/${{ matrix.image }} tags: | type=sha type=edge @@ -30,59 +39,48 @@ jobs: type=semver,pattern={{major}}.{{minor}} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: '${{ github.actor }}' + password: '${{ secrets.GITHUB_TOKEN }}' - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: push: true context: . cache-from: type=gha - file: ./Dockerfile.server - cache-to: type=gha,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-cli: + cache-to: 'type=gha,mode=max' + file: '${{ matrix.dockerfile }}' + tags: '${{ steps.meta.outputs.tags }}' + labels: '${{ steps.meta.outputs.labels }}' + binaries: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: x86_64-unknown-linux-musl - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 + - name: Build + uses: actions-rs/cargo@v1 with: - images: | - ghcr.io/m1guelpf/orbit-cli - tags: | - type=sha - type=edge - type=semver,pattern={{major}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} + command: build + args: '--release --bins' - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + - name: Upload orbit-server binary + uses: actions/upload-artifact@v4 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + name: orbit-server + path: target/release/orbit-server - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 + - name: Upload orbit-cli binary + uses: actions/upload-artifact@v4 with: - push: true - context: . - cache-from: type=gha - file: ./Dockerfile.cli - cache-to: type=gha,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + name: orbit-cli + path: target/release/orbit-cli