Skip to content

Commit

Permalink
Update release ci approach to use a single docker build step
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 4, 2023
1 parent 6dd5d12 commit 87475da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 68 deletions.
75 changes: 22 additions & 53 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ jobs:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
needs: prepare
runs-on: ${{ matrix.job.os }}
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
strategy:
matrix:
job:
Expand Down Expand Up @@ -148,9 +152,6 @@ jobs:
- name: Archive binaries
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }}
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
Expand Down Expand Up @@ -193,18 +194,22 @@ jobs:
files: |
${{ steps.artifacts.outputs.file_name }}
# We move binaries so they match $TARGETPLATFORM in the Docker build
- name: Move Binaries
if: ${{ env.PLATFORM_NAME == 'linux' }}
run: |
mkdir -p $PLATFORM_NAME/$ARCH
mv target/$TARGET/release/katana $PLATFORM_NAME/$ARCH
mv target/$TARGET/release/sozo $PLATFORM_NAME/$ARCH
mv target/$TARGET/release/torii $PLATFORM_NAME/$ARCH
shell: bash

# Upload these for use with the Docker build later
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
target/x86_64-unknown-linux-gnu/release/katana
target/x86_64-unknown-linux-gnu/release/sozo
target/x86_64-unknown-linux-gnu/release/torii
target/aarch64-unknown-linux-gnu/release/katana
target/aarch64-unknown-linux-gnu/release/sozo
target/aarch64-unknown-linux-gnu/release/torii
path: ${{ env.PLATFORM_NAME }}/${{ env.ARCH }}
retention-days: 1

cleanup:
Expand Down Expand Up @@ -232,8 +237,8 @@ jobs:
const prunePrereleases = require('./.github/scripts/prune-prereleases.js')
await prunePrereleases({github, context})
docker-build-and-push-linux-amd64:
name: Build and push linux-amd64 docker image
docker-build-and-push:
name: Build and push docker image
runs-on: ubuntu-latest-4-cores
needs: [prepare, release]

Expand All @@ -245,43 +250,10 @@ jobs:
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v4
with:
build-contexts: |
artifacts=artifacts
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: linux/amd64
target: amd64

docker-build-and-push-linux-arm64:
name: Build and push linux-arm64 docker image
runs-on: ubuntu-latest-4-cores
needs: [prepare, release]

steps:
- name: Checkout repository
uses: actions/checkout@v2
path: artifacts/linux

- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts
- name: Display structure of downloaded files
run: ls -R

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -294,13 +266,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v3
with:
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: linux/arm64
target: arm64
platforms: linux/amd64,linux/arm64
build-contexts: |
artifacts=artifacts
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
FROM debian:bookworm-slim as base

ARG TARGETPLATFORM

LABEL description="Dojo is a provable game engine and toolchain for building onchain games and autonomous worlds with Cairo" \
authors="tarrence <tarrence@cartridge.gg>" \
source="https://github.com/dojoengine/dojo" \
documentation="https://book.dojoengine.org/"

FROM base as amd64

COPY --from=artifacts x86_64-unknown-linux-gnu/release/katana /usr/local/bin/katana
COPY --from=artifacts x86_64-unknown-linux-gnu/release/sozo /usr/local/bin/sozo
COPY --from=artifacts x86_64-unknown-linux-gnu/release/torii /usr/local/bin/torii

RUN chmod +x /usr/local/bin/katana \
&& chmod +x /usr/local/bin/sozo \
&& chmod +x /usr/local/bin/torii

FROM base as arm64

COPY --from=artifacts aarch64-unknown-linux-gnu/release/katana /usr/local/bin/katana
COPY --from=artifacts aarch64-unknown-linux-gnu/release/sozo /usr/local/bin/sozo
COPY --from=artifacts aarch64-unknown-linux-gnu/release/torii /usr/local/bin/torii
COPY --from=artifacts $TARGETPLATFORM/katana /usr/local/bin/katana
COPY --from=artifacts $TARGETPLATFORM/sozo /usr/local/bin/sozo
COPY --from=artifacts $TARGETPLATFORM/torii /usr/local/bin/torii

RUN chmod +x /usr/local/bin/katana \
&& chmod +x /usr/local/bin/sozo \
Expand Down

0 comments on commit 87475da

Please sign in to comment.