Skip to content

Build Docker Images and Binaries #85

Build Docker Images and Binaries

Build Docker Images and Binaries #85

Workflow file for this run

name: Build Docker Images and Binaries
# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:
permissions:
id-token: write
contents: read
packages: write
jobs:
goreleaser:
strategy:
fail-fast: false
matrix:
os:
- linux
arch:
- amd64
- arm64
runs-on: burnt-labs-${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:7}" | tee -a $GITHUB_ENV
sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod | tee -a $GITHUB_ENV
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run GoReleaser
run: |
make build-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: xiond-${{ matrix.os}}-${{ matrix.arch }}
path: dist/${{ env.SHORT_SHA }}/xiond_${{ matrix.os }}_${{ matrix.arch }}/xiond
retention-days: 3
build-docker:
name: main
needs: goreleaser
strategy:
fail-fast: false
matrix:
os:
- linux
arch:
- amd64
- arm64
runs-on: burnt-labs-${{ matrix.arch }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up docker buildx for push
uses: docker/setup-buildx-action@v3
with:
driver: docker
platforms: ${{ matrix.os }}/${{ matrix.arch }}
- name: Prepare environment
run: |
echo "PLATFORM=${{ matrix.os }}/${{ matrix.arch }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "XIOND_FN=xiond/${{ matrix.os }}/${{ matrix.arch }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker/${{ matrix.os }}/${{ matrix.arch }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "HEIGHLINER_FN=heighliner/${{ matrix.os }}/${{ matrix.arch }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "VERSION=$(git describe --tags | sed 's/^v//')" | tee -a $GITHUB_ENV
echo "SHORT_SHA=${GITHUB_SHA:0:7}" | tee -a $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: xiond-${{ matrix.os }}-${{ matrix.arch }}
merge-multiple: true
- uses: int128/docker-build-cache-config-action@v1
id: cache
with:
image: ghcr.io/${{ github.repository }}/cache
- name: Build Docker Image
id: build-docker
uses: docker/build-push-action@v5
with:
build-args: |
COMMIT="${GITHUB_SHA}"
VERSION=${{ env.VERSION }}
TAG_VERSION="${SHORT_SHA}"
CALLER=goreleaser
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}
push: false
target: release
cache-from: ${{ steps.cache.outputs.cache-from }}
cache-to: ${{ steps.cache.outputs.cache-to }}
outputs: type=docker,name=xion:${{ matrix.os }}-${{ matrix.arch }},name-canonical=true
- name: Build Heighliner Image
id: build-heighliner
uses: docker/build-push-action@v5
with:
build-args: |
BASE_IMAGE=xion
VERSION=${{ matrix.os }}-${{ matrix.arch }}
BINARIES=/usr/bin/xiond
CALLER=goreleaser
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}
target: heighliner
outputs: type=docker,name=heighliner:${{ matrix.os }}-${{ matrix.arch }},name-canonical=true
- name: Save Docker Image
working-directory: ${{ runner.temp }}
run: |
docker save xion:${{ matrix.os }}-${{ matrix.arch }} > ${{ env.DOCKER_FN }}
- name: Upload Docker Image
uses: actions/upload-artifact@v4
with:
name: ${{ env.DOCKER_FN }}
path: ${{ runner.temp }}/${{ env.DOCKER_FN }}
if-no-files-found: error
retention-days: 3
- name: Save Heighliner Image
working-directory: ${{ runner.temp }}
run: |
docker save heighliner:${{ matrix.os }}-${{ matrix.arch }} > ${{ env.HEIGHLINER_FN }}
- name: Upload Heighliner Image
uses: actions/upload-artifact@v4
with:
name: ${{ env.HEIGHLINER_FN }}
path: ${{ runner.temp }}/${{ env.HEIGHLINER_FN }}
if-no-files-found: error
retention-days: 3