mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 10:17:45 +08:00
ci(packaging): publish container images with :latest tag
Add :latest tag alongside version tags for per-arch images and multi-arch manifests on both Docker Hub and GHCR. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
@@ -27,9 +27,6 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
env:
|
|
||||||
RUNS_IN_DOCKER: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -39,8 +36,8 @@ jobs:
|
|||||||
name: Setup
|
name: Setup
|
||||||
runs-on: [runs-on,"runner=1cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",extras=s3-cache,spot=false]
|
runs-on: [runs-on,"runner=1cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",extras=s3-cache,spot=false]
|
||||||
outputs:
|
outputs:
|
||||||
px4_version: ${{ steps.px4_version.outputs.px4_version }}
|
px4_version: ${{ steps.version.outputs.px4_version }}
|
||||||
should_push: ${{ steps.push_check.outputs.should_push }}
|
should_push: ${{ steps.push.outputs.should_push }}
|
||||||
steps:
|
steps:
|
||||||
- uses: runs-on/action@v2
|
- uses: runs-on/action@v2
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -50,11 +47,11 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set PX4 version
|
- name: Set PX4 version
|
||||||
id: px4_version
|
id: version
|
||||||
run: echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
|
run: echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Check if we should push containers
|
- name: Check if we should push containers
|
||||||
id: push_check
|
id: push
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]] || \
|
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]] || \
|
||||||
[[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.deploy_containers }}" == "true" ]]; then
|
[[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.deploy_containers }}" == "true" ]]; then
|
||||||
@@ -78,16 +75,16 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# Gazebo builds
|
|
||||||
- { codename: noble, arch: amd64, runner: x64, container: "ubuntu:24.04", target: default, setup_flags: "" }
|
- { codename: noble, arch: amd64, runner: x64, container: "ubuntu:24.04", target: default, setup_flags: "" }
|
||||||
- { codename: noble, arch: arm64, runner: arm64, container: "ubuntu:24.04", target: default, setup_flags: "" }
|
- { codename: noble, arch: arm64, runner: arm64, container: "ubuntu:24.04", target: default, setup_flags: "" }
|
||||||
- { codename: jammy, arch: amd64, runner: x64, container: "ubuntu:22.04", target: default, setup_flags: "" }
|
- { codename: jammy, arch: amd64, runner: x64, container: "ubuntu:22.04", target: default, setup_flags: "" }
|
||||||
- { codename: jammy, arch: arm64, runner: arm64, container: "ubuntu:22.04", target: default, setup_flags: "" }
|
- { codename: jammy, arch: arm64, runner: arm64, container: "ubuntu:22.04", target: default, setup_flags: "" }
|
||||||
# SIH builds
|
|
||||||
- { codename: noble, arch: amd64, runner: x64, container: "ubuntu:24.04", target: sih, setup_flags: "--no-sim-tools" }
|
- { codename: noble, arch: amd64, runner: x64, container: "ubuntu:24.04", target: sih, setup_flags: "--no-sim-tools" }
|
||||||
- { codename: noble, arch: arm64, runner: arm64, container: "ubuntu:24.04", target: sih, setup_flags: "--no-sim-tools" }
|
- { codename: noble, arch: arm64, runner: arm64, container: "ubuntu:24.04", target: sih, setup_flags: "--no-sim-tools" }
|
||||||
- { codename: jammy, arch: amd64, runner: x64, container: "ubuntu:22.04", target: sih, setup_flags: "--no-sim-tools" }
|
- { codename: jammy, arch: amd64, runner: x64, container: "ubuntu:22.04", target: sih, setup_flags: "--no-sim-tools" }
|
||||||
- { codename: jammy, arch: arm64, runner: arm64, container: "ubuntu:22.04", target: sih, setup_flags: "--no-sim-tools" }
|
- { codename: jammy, arch: arm64, runner: arm64, container: "ubuntu:22.04", target: sih, setup_flags: "--no-sim-tools" }
|
||||||
|
env:
|
||||||
|
RUNS_IN_DOCKER: true
|
||||||
steps:
|
steps:
|
||||||
- uses: runs-on/action@v2
|
- uses: runs-on/action@v2
|
||||||
|
|
||||||
@@ -147,24 +144,13 @@ jobs:
|
|||||||
path: docker-context
|
path: docker-context
|
||||||
|
|
||||||
- name: Prepare build context
|
- name: Prepare build context
|
||||||
|
run: cp Tools/packaging/px4-entrypoint.sh docker-context/
|
||||||
|
|
||||||
|
- name: Login to registries
|
||||||
|
if: needs.setup.outputs.should_push == 'true'
|
||||||
run: |
|
run: |
|
||||||
cp Tools/packaging/px4-entrypoint.sh docker-context/
|
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
||||||
ls -lh docker-context/
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
if: needs.setup.outputs.should_push == 'true'
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
if: needs.setup.outputs.should_push == 'true'
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -179,7 +165,9 @@ jobs:
|
|||||||
file: Tools/packaging/${{ matrix.dockerfile }}
|
file: Tools/packaging/${{ matrix.dockerfile }}
|
||||||
tags: |
|
tags: |
|
||||||
px4io/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
|
px4io/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
|
||||||
|
px4io/px4-sitl-${{ matrix.image }}:latest-${{ matrix.arch }}
|
||||||
ghcr.io/px4/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
|
ghcr.io/px4/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
|
||||||
|
ghcr.io/px4/px4-sitl-${{ matrix.image }}:latest-${{ matrix.arch }}
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
load: false
|
load: false
|
||||||
push: ${{ needs.setup.outputs.should_push == 'true' }}
|
push: ${{ needs.setup.outputs.should_push == 'true' }}
|
||||||
@@ -201,52 +189,26 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: runs-on/action@v2
|
- uses: runs-on/action@v2
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to registries
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Verify per-arch images exist
|
|
||||||
run: |
|
run: |
|
||||||
for registry in px4io ghcr.io/px4; do
|
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
||||||
for arch in amd64 arm64; do
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
||||||
docker manifest inspect ${registry}/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${arch} \
|
|
||||||
|| echo "Warning: ${registry}/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${arch} not found"
|
- name: Create and push multi-arch manifests
|
||||||
|
run: |
|
||||||
|
VERSION="${{ needs.setup.outputs.px4_version }}"
|
||||||
|
|
||||||
|
for REGISTRY in px4io ghcr.io/px4; do
|
||||||
|
IMAGE="${REGISTRY}/px4-sitl-${{ matrix.image }}"
|
||||||
|
|
||||||
|
for TAG in ${VERSION} latest; do
|
||||||
|
docker manifest create ${IMAGE}:${TAG} \
|
||||||
|
--amend ${IMAGE}:${TAG}-arm64 \
|
||||||
|
--amend ${IMAGE}:${TAG}-amd64
|
||||||
|
|
||||||
|
docker manifest annotate ${IMAGE}:${TAG} ${IMAGE}:${TAG}-arm64 --arch arm64
|
||||||
|
docker manifest annotate ${IMAGE}:${TAG} ${IMAGE}:${TAG}-amd64 --arch amd64
|
||||||
|
|
||||||
|
docker manifest push ${IMAGE}:${TAG}
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Create and push multi-arch manifest (Docker Hub)
|
|
||||||
run: |
|
|
||||||
VERSION="${{ needs.setup.outputs.px4_version }}"
|
|
||||||
IMAGE="px4io/px4-sitl-${{ matrix.image }}"
|
|
||||||
|
|
||||||
docker manifest create ${IMAGE}:${VERSION} \
|
|
||||||
--amend ${IMAGE}:${VERSION}-arm64 \
|
|
||||||
--amend ${IMAGE}:${VERSION}-amd64
|
|
||||||
|
|
||||||
docker manifest annotate ${IMAGE}:${VERSION} ${IMAGE}:${VERSION}-arm64 --arch arm64
|
|
||||||
docker manifest annotate ${IMAGE}:${VERSION} ${IMAGE}:${VERSION}-amd64 --arch amd64
|
|
||||||
|
|
||||||
docker manifest push ${IMAGE}:${VERSION}
|
|
||||||
|
|
||||||
- name: Create and push multi-arch manifest (GHCR)
|
|
||||||
run: |
|
|
||||||
VERSION="${{ needs.setup.outputs.px4_version }}"
|
|
||||||
IMAGE="ghcr.io/px4/px4-sitl-${{ matrix.image }}"
|
|
||||||
|
|
||||||
docker manifest create ${IMAGE}:${VERSION} \
|
|
||||||
--amend ${IMAGE}:${VERSION}-arm64 \
|
|
||||||
--amend ${IMAGE}:${VERSION}-amd64
|
|
||||||
|
|
||||||
docker manifest annotate ${IMAGE}:${VERSION} ${IMAGE}:${VERSION}-arm64 --arch arm64
|
|
||||||
docker manifest annotate ${IMAGE}:${VERSION} ${IMAGE}:${VERSION}-amd64 --arch amd64
|
|
||||||
|
|
||||||
docker manifest push ${IMAGE}:${VERSION}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user