Switch to GHA and GHCR for image building and hosting #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Georust Docker Images | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
- trying | |
pull_request: | |
merge_group: | |
env: | |
LIBPROJ_VERSION: 9.4.0 | |
MAIN_IMAGE_NAME: libproj-builder | |
jobs: | |
build_main_image: | |
name: Build the main image for geo and proj | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust_version: [1.77] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Builder | |
run: | | |
docker buildx create --name mybuilder | |
docker buildx use mybuilder | |
docker buildx inspect --bootstrap | |
- name: Build and export main image to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ env.MAIN_IMAGE_NAME }} | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.MAIN_IMAGE_NAME }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
- name: Push tested main image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ env.MAIN_IMAGE_NAME }} | |
push: true | |
load: false | |
# platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.MAIN_IMAGE_NAME }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
outputs: type=docker,dest=/tmp/${{ env.MAIN_IMAGE_NAME }}-proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }}.tar | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
build_dependent_images: | |
name: Build dependent images for geo and proj | |
needs: build_main_image | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
subimages: [ | |
{image: geo-ci, testcmd: "git clone https://github.com/georust/geo && cd geo && cargo test --no-default-features && cargo test && cargo test --all-features"}, | |
{image: proj-ci, testcmd: "git clone https://github.com/georust/proj && cd proj && cargo test --no-default-features && cargo test --features bundled_proj && cargo test --features network"}, | |
{image: proj-ci-without-system-proj, testcmd: "git clone https://github.com/georust/proj && cd proj && _PROJ_SYS_TEST_EXPECT_BUILD_FROM_SRC=1 cargo test --features bundled_proj"} | |
] | |
rust_version: [1.77] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Builder | |
run: | | |
docker buildx create --name mybuilder | |
docker buildx use mybuilder | |
docker buildx inspect --bootstrap | |
- name: Build ${{ matrix.subimages.image }} | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ matrix.subimages.image }} | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.subimages.image }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
- name: Test ${{ matrix.subimages.image }} | |
run: | | |
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ matrix.subimages.image }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} /bin/bash -c "${{ matrix.subimages.testcmd }}" | |
- name: Push tested ${{ matrix.subimages.image }} image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ matrix.subimages.image }} | |
push: true | |
load: false | |
# platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.subimages.image }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
outputs: type=docker,dest=/tmp/${{ matrix.subimages.image }}-proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }}.tar | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} |