mirror of
https://github.com/lukaszraczylo/tdlib-telegram-bot-api-docker.git
synced 2026-06-05 22:33:43 +00:00
Improve build process.
This commit is contained in:
@@ -6,7 +6,12 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
name: Build amd64 and arm64 images
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
name: Build ${{ matrix.platform }} image
|
||||
steps:
|
||||
- name: Checkout API repo
|
||||
uses: actions/checkout@v2
|
||||
@@ -48,13 +53,16 @@ jobs:
|
||||
if [ "${{ github.event_name }}" = "schedule" ]; then
|
||||
VERSION=nightly
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
||||
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
||||
fi
|
||||
# Platform-specific tag for this build job
|
||||
PLATFORM_TAG=$(echo ${{ matrix.platform }} | sed 's/\//-/g')
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION}-${PLATFORM_TAG}"
|
||||
TAGS="$TAGS,${DOCKER_IMAGE}:${{ env.GITHUB_SHA }}-${PLATFORM_TAG}"
|
||||
|
||||
TG_API_VERSION=$(grep "project(TelegramBotApi" /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/CMakeLists.txt | awk '{print $3}')
|
||||
TAGS="$TAGS,$DOCKER_IMAGE:${{ env.GITHUB_SHA }},$DOCKER_IMAGE:1.0.${{ env.GITHUB_RUN_ID }},$DOCKER_IMAGE:latest,$DOCKER_IMAGE:api-$TG_API_VERSION"
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=version::${VERSION}
|
||||
echo ::set-output name=tg_api_version::${TG_API_VERSION}
|
||||
echo ::set-output name=image::${DOCKER_IMAGE}
|
||||
# lowercase the branch name
|
||||
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
||||
LABELS="org.opencontainers.image.revision=$GITHUB_SHA"
|
||||
@@ -69,16 +77,67 @@ jobs:
|
||||
run: echo ${{ steps.prep.outputs.tags }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
timeout-minutes: 900
|
||||
timeout-minutes: 350
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api
|
||||
file: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/Dockerfile
|
||||
platforms: linux/arm64,linux/amd64
|
||||
platforms: ${{ matrix.platform }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
build-args: ${{ steps.prep.outputs.args }}
|
||||
labels: ${{ steps.prep.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-from: type=gha,scope=${{ matrix.platform }}
|
||||
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
|
||||
outputs:
|
||||
version: ${{ steps.prep.outputs.version }}
|
||||
tg_api_version: ${{ steps.prep.outputs.tg_api_version }}
|
||||
image: ${{ steps.prep.outputs.image }}
|
||||
|
||||
create-manifest:
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
if: github.event_name != 'pull_request'
|
||||
name: Create multi-arch manifest
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GCHR_PAT }}
|
||||
- name: Get build outputs
|
||||
id: outputs
|
||||
run: |
|
||||
echo "VERSION=${{ needs.build.outputs.version }}" >> $GITHUB_ENV
|
||||
echo "TG_API_VERSION=${{ needs.build.outputs.tg_api_version }}" >> $GITHUB_ENV
|
||||
echo "IMAGE=${{ needs.build.outputs.image }}" >> $GITHUB_ENV
|
||||
- name: Create and push manifest
|
||||
run: |
|
||||
# Create multi-arch manifests for all tags
|
||||
docker buildx imagetools create -t ${IMAGE}:${VERSION} \
|
||||
${IMAGE}:${VERSION}-linux-amd64 \
|
||||
${IMAGE}:${VERSION}-linux-arm64
|
||||
|
||||
docker buildx imagetools create -t ${IMAGE}:${GITHUB_SHA::8} \
|
||||
${IMAGE}:${GITHUB_SHA::8}-linux-amd64 \
|
||||
${IMAGE}:${GITHUB_SHA::8}-linux-arm64
|
||||
|
||||
docker buildx imagetools create -t ${IMAGE}:latest \
|
||||
${IMAGE}:${VERSION}-linux-amd64 \
|
||||
${IMAGE}:${VERSION}-linux-arm64
|
||||
|
||||
docker buildx imagetools create -t ${IMAGE}:1.0.${GITHUB_RUN_NUMBER} \
|
||||
${IMAGE}:${VERSION}-linux-amd64 \
|
||||
${IMAGE}:${VERSION}-linux-arm64
|
||||
|
||||
docker buildx imagetools create -t ${IMAGE}:api-${TG_API_VERSION} \
|
||||
${IMAGE}:${VERSION}-linux-amd64 \
|
||||
${IMAGE}:${VERSION}-linux-arm64
|
||||
- name: Inspect manifest
|
||||
run: |
|
||||
docker buildx imagetools inspect ${IMAGE}:${VERSION}
|
||||
docker buildx imagetools inspect ${IMAGE}:latest
|
||||
|
||||
Reference in New Issue
Block a user