Skip to content

Commit

Permalink
ci: restore docker builds (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored May 27, 2024
1 parent 124e742 commit 1be9561
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Docker
on:
workflow_dispatch: {}
push:
tags:
- "v*"

jobs:
build:
continue-on-error: true

strategy:
matrix:
include:
# don't change `Linux` or `x86_64` to avoid breaking the
# install script because it relies on the `uname` outputs
- release_for: Linux-x86_64
build_on: ubuntu-latest
target: x86_64-unknown-linux-gnu
args: "--locked --release"

# don't change `Linux` or `arm64` to avoid breaking the
# install script because it relies on the `uname` outputs
- release_for: Linux-arm64
build_on: ubuntu-latest
target: "aarch64-unknown-linux-gnu"
# we skip mithril because of no support for cross compile
# args: "--locked --release --no-default-features"
args: "--locked --release"

runs-on: ${{ matrix.build_on }}

steps:
- name: checkout repository
uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
shared-key: "release"

- name: build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.target }}
args: ${{ matrix.args }}
strip: true

- name: rename binaries
run: |
mv target/${{ matrix.target }}/release/dolos${{ matrix.ext }} dolos-${{ matrix.release_for }}${{ matrix.ext }}
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.release_for }}
path: dolos-${{ matrix.release_for }}${{ matrix.ext }}

docker:
runs-on: ubuntu-latest
needs: [build]

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/txpipe/dolos
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io/txpipe
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true
path: .github/image/bin

# we need to rename the artifact so that the name matches
# the value that Docker uses for TARGET_ARCH to keep the
# Dockerfile simple
- name: Rename artifacts
run: |+
mv .github/image/bin/dolos-Linux-x86_64 .github/image/bin/dolos-Linux-amd64
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .github/image
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 1be9561

Please sign in to comment.