Skip to content

Build and push docker image and package #35

Build and push docker image and package

Build and push docker image and package #35

name: Build and push docker image
on:
release:
types:
- published
workflow_dispatch:
inputs:
release_tag:
description: "Release tag version to tag image, e.g. v0.1.1"
required: true
type: string
jobs:
get-release-tag:
name: Get release tag
runs-on: ubuntu-latest
steps:
- name: Get release tag
id: get_release_tag
run: echo "::set-output name=release_tag::${{ github.event.release.tag_name || github.event.inputs.release_tag }}"
build-and-push:
name: Build and push docker image
needs: get-release-tag
strategy:
matrix:
os: [ubuntu-latest, ARM64]
include:
- os: ubuntu-latest
build-platform: linux/amd64
- os: ARM64
build-platform: linux/arm64
runs-on: ${{ matrix.os }}
steps:
- name: checkout code
uses: actions/checkout@v4
- name: set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.4'
check-latest: true
- name: install poetry
run: |
python -m pip install --no-cache-dir poetry==1.8 supervisor
poetry self add "poetry-dynamic-versioning[plugin]"
- name: set up docker
run: |
make gha-setup
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Poetry
run: make build-wheel
- name: Build Docker image
run: |
docker build \
--platform ${{ matrix.build-platform }} \
--output type=docker \
-t ghcr.io/${{ github.repository }}:${{ needs.get-release-tag.outputs.release_tag }}-${{ matrix.build-platform }} \
.
- name: Push Docker image
run: |
docker push ghcr.io/${{ github.repository }}:${{ needs.get-release-tag.outputs.release_tag }}-${{ matrix.build-platform }}
manifest:
name: Create and push multi-architecture manifest
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest
run: |
docker buildx imagetools create \
-t ghcr.io/${{ github.repository }}:${{ needs.get-release-tag.outputs.release_tag }} \
-t ghcr.io/${{ github.repository }}:latest \
ghcr.io/${{ github.repository }}:${{ needs.get-release-tag.outputs.release_tag }}-linux/amd64 \
ghcr.io/${{ github.repository }}:${{ needs.get-release-tag.outputs.release_tag }}-linux/arm64