Skip to content

fix: suffix

fix: suffix #324

Workflow file for this run

# Copyright 2023 UMH Systems GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: main
on:
push:
branches:
- '**'
tags:
- v*
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-docker:
permissions:
packages: write
contents: read
timeout-minutes: 60
strategy:
matrix:
architecture: ['amd64', 'arm64', 'arm/v7']
runs-on:
group: ${{ matrix.architecture == 'arm64' && 'arc-runners-small' || matrix.architecture == 'arm/v7' && 'arc-runners-small' || 'arc-runners' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
env:
PR_ID: ${{ github.event.pull_request.number }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request && github.head_ref || github.ref_name }}
- name: Check if Docker daemon is running
id: check_docker
run: |
SECONDS=0
TIMEOUT=120
while ! docker info >/dev/null 2>&1; do
if [ $SECONDS -ge $TIMEOUT ]; then
echo "Docker daemon is not running after ${TIMEOUT} seconds, exiting..."
docker info
exit 1
fi
echo "Waiting for Docker daemon to start..."
sleep 1
done
echo "Docker daemon is running."
- name: Login to GitHub Container registry
uses: docker/login-action@v3
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
registry: ghcr.io
username: $GITHUB_USER
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
image: management.umh.app/oci/tonistiigi/binfmt:latest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set PLATFORM_SHORT
id: platform_short
shell: bash
run: |
PLATFORM_SHORT="${{ matrix.architecture }}"
PLATFORM_SHORT="${PLATFORM_SHORT//\//-}"
echo "PLATFORM_SHORT=${PLATFORM_SHORT}" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-${{ steps.platform_short.outputs.PLATFORM_SHORT }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern=latest,include_prereleases=false
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
push: true
platforms: linux/${{ matrix.architecture }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=${{ steps.meta.outputs.version }}
provenance: false
file: ./Dockerfile
create-manifests:
needs: build-docker
if: needs.build-docker.outputs.tags != ''
permissions:
contents: read
packages: write
runs-on:
group: arc-runners
defaults:
run:
shell: bash
steps:
- name: Login to GitHub Container registry
uses: docker/login-action@v3
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
registry: ghcr.io
username: $GITHUB_USER
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create multiarch manifests
run: |
# Get the list of tags
TAGS="${{ needs.build-docker.outputs.tags }}"
echo "TAGS: $TAGS"
# Split tags into an array
IFS=',' read -ra TAG_ARRAY <<< "$TAGS"
# Define architectures
ARCHITECTURES=("amd64" "arm64" "arm/v7")
# Create manifests for each tag
for TAG in "${TAG_ARRAY[@]}"; do
echo "Processing tag $TAG"
# Construct platform-specific tags
PLATFORM_TAGS=""
for ARCH in "${ARCHITECTURES[@]}"; do
PLATFORM_SHORT="${ARCH//\//-}"
PLATFORM_TAG="${TAG}-${PLATFORM_SHORT}"
PLATFORM_TAGS="${PLATFORM_TAGS} ${PLATFORM_TAG}"
done
echo "Creating manifest for $TAG from $PLATFORM_TAGS"
docker buildx imagetools create -t "${TAG}" ${PLATFORM_TAGS}
done
build-binaries:
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: linux
goarch: armv7
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
runs-on:
group: ${{ matrix.architecture == 'arm64' && 'arc-runners-small' || matrix.architecture == 'armv7' && 'arc-runners-small' || 'arc-runners' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request && github.head_ref || github.ref_name }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
image: management.umh.app/oci/tonistiigi/binfmt:latest
- name: Install Cross-Compilers
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib gcc-mingw-w64
- name: Set up Build Environment
run: |
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
if [ "${{ matrix.goarch }}" == "armv7" ]; then
echo "GOARM=7" >> $GITHUB_ENV
echo "GOARCH=arm" >> $GITHUB_ENV
else
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
fi
if [ "${{ matrix.goos }}" == "windows" ]; then
echo "FILE_EXTENSION=.exe" >> $GITHUB_ENV
else
echo "FILE_EXTENSION=" >> $GITHUB_ENV
fi
echo "OUTPUT_NAME=benthos-${{ matrix.goos }}-${{ matrix.goarch }}$(FILE_EXTENSION)"
echo "OUTPUT_NAME=benthos-${{ matrix.goos }}-${{ matrix.goarch }}$(FILE_EXTENSION)" >> $GITHUB_ENV
- name: Print working directory
run: pwd
- name: List files in working directory
run: ls -la
- name: Build Binary
run: |
mkdir -p ./dist
GOOS=${{ env.GOOS }} GOARCH=${{ env.GOARCH }} GOARM=${{ env.GOARM }} \
CGO_ENABLED=0 GOPROXY=https://golangproxy.umh.app,https://proxy.golang.org,direct \
go build \
-ldflags "-s -w \
-X github.com/redpanda-data/benthos/v4/internal/cli.Version=${APP_VERSION} \
-X github.com/redpanda-data/benthos/v4/internal/cli.DateBuilt=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o ./dist/${{ env.OUTPUT_NAME }} \
cmd/benthos/main.go
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: binaries
path: ./dist/${{ env.OUTPUT_NAME }}
release:
if: needs.build-binaries.result == 'success'
needs: build-binaries
permissions:
contents: write
runs-on:
group: arc-runners # Use your own runners
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: binaries
path: ./artifacts
- name: Create or Update Release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
artifacts: './artifacts/*'
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}