Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Make sure we can push tagged builds to ghcr #92

Make sure we can push tagged builds to ghcr

Make sure we can push tagged builds to ghcr #92

# /********************************************************************************
# * Copyright (c) 2022 Contributors to the Eclipse Foundation
# *
# * See the NOTICE file(s) distributed with this work for additional
# * information regarding copyright ownership.
# *
# * This program and the accompanying materials are made available under the
# * terms of the Apache License 2.0 which is available at
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/
name: someip2val-build
on:
push:
branches: [ main ]
pull_request:
paths:
- ".github/workflows/someip2val_build.yml"
- ".github/workflows/check_push_rights.yml"
- "someip2val/**"
workflow_dispatch:
inputs:
build_binaries:
description: 'Build Binaries'
required: false
default: 'false'
jobs:
checkrights:
uses: ./.github/workflows/check_push_rights.yml
secrets: inherit
build:
name: Build Binaries
# build if explicitly requested or merging to main
if: ${{ github.event.inputs.build_binaries == 'true' || (needs.checkrights.outputs.have_secrets == 'true' && github.event_name != 'pull_request') }}
# reduce runtime requirements from ubuntu, ubuntu-18.04 fails for aarch64
runs-on: ubuntu-20.04
strategy:
matrix:
target-arch: [x86_64, aarch64]
fail-fast: true
steps:
- name: Install Pre-requisities
run: |
sudo apt-get update -qqy && \
sudo apt-get install -qqy --no-install-recommends \
cmake g++ build-essential \
g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \
jq python3 python3-pip python3-setuptools &&
pip3 install conan==1.55.0
- name: Checkout
uses: actions/checkout@v3
- name: Run build
working-directory: ${{github.workspace}}/someip2val
run: ./build-release.sh ${{ matrix.target-arch }}
- name: Upload Binaries
uses: actions/upload-artifact@v3
with:
name: someip2val_${{ matrix.target-arch }}_release
path: |
${{github.workspace}}/someip2val/target/${{ matrix.target-arch }}/release/install/bin
${{github.workspace}}/someip2val/target/${{ matrix.target-arch }}/release/install/lib/libvsomeip*.so.3
if-no-files-found: error
build_docker:
# reduce runtime requirements from ubuntu, ubuntu-18.04 fails for aarch64
runs-on: ubuntu-20.04
name: Build Docker
needs: checkrights
steps:
- name: Check Setup
env:
OUT_HAVE_SECRETS: ${{ needs.checkrights.outputs.have_secrets }}
OUT_USER_NAME: ${{ github.repository_owner }}
OUT_EVENT_NAME: ${{ github.event_name }}
run: |
echo
echo "### have_secrets : $OUT_HAVE_SECRETS"
echo "### username : $OUT_USER_NAME"
echo "### event_name : $OUT_EVENT_NAME"
echo
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
if: needs.checkrights.outputs.have_secrets == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}/someip-feeder
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: "Build someip2val container and push to ghcr.io"
if: ${{ needs.checkrights.outputs.have_secrets == 'true' && github.event_name != 'pull_request' }}
id: image_build_ghcr
uses: docker/build-push-action@v4
with:
pull: false
push: true
file: ./someip2val/Dockerfile
context: "./someip2val"
platforms: linux/amd64, linux/arm64
tags: |
${{ steps.meta.outputs.tags }}
ttl.sh/kuksa.val.feeders/someip-feeder-${{github.sha}}
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
provenance: false
- name: "Build someip2val container and push to ttl.sh"
if: ${{ needs.checkrights.outputs.have_secrets != 'true' || github.event_name == 'pull_request' }}
id: image_build_ttl
uses: docker/build-push-action@v4
with:
pull: false
push: true
file: ./someip2val/Dockerfile
context: "./someip2val"
platforms: linux/amd64, linux/arm64
tags: |
ttl.sh/kuksa.val.feeders/someip-feeder-${{github.sha}}
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
provenance: false