Skip to content

Merge branch 'ISAITB-master' #38

Merge branch 'ISAITB-master'

Merge branch 'ISAITB-master' #38

Workflow file for this run

name: Create and publish SHACL API Docker image
on:
release:
type: [published]
push:
branches: [master]
env:
REGISTRY: ghcr.io
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
package:
[
"x86_64",
"arm64"
]
include:
- package: "x86_64"
platform: linux/amd64
base: eclipse-temurin:21-alpine
- package: "arm64"
platform: linux/arm64
base: amazoncorretto:21-alpine3.20-jdk
steps:
- name: lowercase image name
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
# inspired by https://github.com/reloc8/action-latest-release-version
- name: Get release version
id: get_version
run: |
git fetch --tags -f
git fetch --prune --unshallow || true
LATEST_RELEASE=$(git describe --abbrev=0 --tags | sed 's/^v//')
echo "latest-release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT
echo "version_build=${LATEST_RELEASE}_"$(git rev-parse --short "$GITHUB_SHA") >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
type=raw,value=${{ steps.get_version.outputs.version_build}},enable=${{ github.event_name == 'push' }}
type=raw,value=${{ steps.get_version.outputs.latest-release}},enable=${{ github.event_name == 'release' }}
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image for x86 and arm64
id: build
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
file: .docker/Dockerfile
push: true
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.get_version.outputs.version_build }}
ARCH_BASE=${{ matrix.base }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: digests-${{ matrix.package }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- build-and-push-image
steps:
- name: lowercase image name
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# inspired by https://github.com/reloc8/action-latest-release-version
- name: Get release version
id: get_version
run: |
git fetch --tags
git fetch --prune --unshallow || true
LATEST_RELEASE=$(git describe --abbrev=0 --tags | sed 's/^v//')
echo "latest-release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT
echo "version_build=${LATEST_RELEASE}_"$(git rev-parse --short "$GITHUB_SHA") >> $GITHUB_OUTPUT
- name: Download digests
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
type=raw,value=${{ steps.get_version.outputs.version_build}},enable=${{ github.event_name == 'push' }}
type=raw,value=${{ steps.get_version.outputs.latest-release}},enable=${{ github.event_name == 'release' }}
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}