Toolshed (ts): Ubuntu 24.04 Release 2 #88
Workflow file for this run
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: ghcr.io/opencyphal/toolshed container build and publish. | |
on: | |
release: | |
types: [ published ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
REGISTRY_IMAGE: ghcr.io/opencyphal/toolshed | |
IMAGE_VERSION_PREFIX: ts | |
jobs: | |
release-ts-amd64: | |
if: > | |
( github.event_name == 'pull_request' && contains(github.event.pull_request.title, '#ts')) || | |
( github.event_name == 'release' && startsWith(github.ref, 'refs/tags/ts')) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: | |
- linux/amd64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- # Setup buildx so we can do multi-platform container builds. | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease}} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: toolshed | |
platforms: ${{ matrix.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ (github.event_name != 'pull_request' && !github.event.release.prerelease) && 'true' || 'false' }} | |
- name: Export digest | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease}} | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
release-ts-arm64: | |
if: > | |
( github.event_name == 'pull_request' && contains(github.event.pull_request.title, '#ts')) || | |
( github.event_name == 'release' && startsWith(github.ref, 'refs/tags/ts')) | |
runs-on: ubuntu-24.04-arm | |
strategy: | |
matrix: | |
platform: | |
- linux/arm64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- # Setup buildx so we can do multi-platform container builds. | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease}} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: toolshed | |
platforms: ${{ matrix.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ (github.event_name != 'pull_request' && !github.event.release.prerelease) && 'true' || 'false' }} | |
- name: Export digest | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease}} | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
if: ${{ github.event_name != 'pull_request' && !github.event.release.prerelease }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge-ts: | |
if: > | |
github.event_name == 'release' && | |
startsWith( github.ref, 'refs/tags/ts' ) && | |
!github.event.release.prerelease | |
runs-on: ubuntu-latest | |
needs: | |
- release-ts-amd64 | |
- release-ts-arm64 | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
tags: type=ref,event=tag | |
images: ${{ env.REGISTRY_IMAGE }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
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_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |