Skip to content

Commit

Permalink
ci: build nightly for amd64 and arm64
Browse files Browse the repository at this point in the history
Signed-off-by: Aljoscha Poertner <[email protected]>
  • Loading branch information
aljoshare committed Oct 14, 2023
1 parent c78ef31 commit d440569
Showing 1 changed file with 73 additions and 10 deletions.
83 changes: 73 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,42 @@ jobs:
name: Build a nightly version of runo
runs-on: ubuntu-latest
needs: coverage
strategy:
fail-fast: false
matrix:
recipe:
- { target: aarch64-unknown-linux-gnu, platform: linux/arm64 }
- { target: x86_64-unknown-linux-gnu, platform: linux/amd64 }
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.recipe.target }}
override: true
- name: Build binary
run: cargo build
- name: Compress binary
run: zip target/debug/runo.zip target/debug/runo
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.recipe.target }}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: binary
path: target/debug/runo.zip
retention-days: 30
name: ${{ matrix.recipe.target }}
path: target/${{ matrix.recipe.target }}/debug/runo
retention-days: 5
image:
name: Build and push image
runs-on: ubuntu-latest
needs: coverage
needs: build
strategy:
fail-fast: false
matrix:
recipe:
- { target: aarch64-unknown-linux-gnu, platform: linux/arm64 }
- { target: x86_64-unknown-linux-gnu, platform: linux/amd64 }
permissions:
contents: read
packages: write
Expand All @@ -76,6 +90,10 @@ jobs:
- name: Debug
run: |
echo "github.ref -> {{ github.ref }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -89,11 +107,56 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{sha}}
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.recipe.target }}
- name: Build and push image
id: build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
platforms: ${{ matrix.recipe.platform }}
labels: ${{ steps.metadata.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- image
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

0 comments on commit d440569

Please sign in to comment.