|
| 1 | +# ******************************************************************************** |
| 2 | +# Copyright (c) 2025 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# *******************************************************************************/ |
| 13 | + |
| 14 | +name: Containerize uStreamer and Push to Container Registry |
| 15 | + |
| 16 | +on: |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +env: |
| 20 | + REGISTRY: ghcr.io |
| 21 | + IMAGE_NAME: ${{ github.repository }}/configurable-streamer |
| 22 | + |
| 23 | +jobs: |
| 24 | + setup: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + tags: ${{ steps.meta.outputs.tags }} |
| 28 | + labels: ${{ steps.meta.outputs.labels }} |
| 29 | + steps: |
| 30 | + - name: Extract metadata and create tag |
| 31 | + id: meta |
| 32 | + uses: docker/metadata-action@v5 |
| 33 | + with: |
| 34 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 35 | + tags: | |
| 36 | + type=ref,event=branch |
| 37 | + type=ref,event=tag |
| 38 | + type=ref,event=pr |
| 39 | +
|
| 40 | + build-arm64: |
| 41 | + needs: setup |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + packages: write |
| 46 | + outputs: |
| 47 | + digest: ${{ steps.build_and_push.outputs.digest }} |
| 48 | + steps: |
| 49 | + - name: Checkout repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up Docker buildx |
| 53 | + uses: docker/setup-buildx-action@v3 |
| 54 | + |
| 55 | + - name: Login to the Container registry |
| 56 | + uses: docker/login-action@v3 |
| 57 | + with: |
| 58 | + registry: ${{ env.REGISTRY }} |
| 59 | + username: ${{ github.actor }} |
| 60 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + - name: Install Rust and Cross |
| 63 | + uses: ./.github/actions/setup-rust-cross |
| 64 | + |
| 65 | + - name: Cross Build for arm64 |
| 66 | + working-directory: configurable-streamer |
| 67 | + run: | |
| 68 | + cross build --target aarch64-unknown-linux-musl --release |
| 69 | +
|
| 70 | + - name: Fix Registry and Repository names |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + echo "REGISTRY=$(echo $REGISTRY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 74 | + echo "IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + - name: Build and push Docker image for arm64 |
| 77 | + id: build_and_push |
| 78 | + uses: docker/build-push-action@v5 |
| 79 | + with: |
| 80 | + context: . |
| 81 | + file: "configurable-streamer/Dockerfile.arm" |
| 82 | + push: true |
| 83 | + platforms: linux/arm64 |
| 84 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64-${{ github.sha }} |
| 85 | + labels: ${{ needs.setup.outputs.labels }} |
| 86 | + |
| 87 | + build-amd64: |
| 88 | + needs: setup |
| 89 | + runs-on: ubuntu-latest |
| 90 | + outputs: |
| 91 | + digest: ${{ steps.build_and_push.outputs.digest }} |
| 92 | + steps: |
| 93 | + - name: Checkout repository |
| 94 | + uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - name: Set up Docker buildx |
| 97 | + uses: docker/setup-buildx-action@v3 |
| 98 | + |
| 99 | + - name: Login to the Container registry |
| 100 | + uses: docker/login-action@v3 |
| 101 | + with: |
| 102 | + registry: ${{ env.REGISTRY }} |
| 103 | + username: ${{ github.actor }} |
| 104 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + |
| 106 | + - name: Install Rust and Cross |
| 107 | + uses: ./.github/actions/setup-rust-cross |
| 108 | + |
| 109 | + - name: Cross Build for amd64 |
| 110 | + working-directory: configurable-streamer |
| 111 | + run: | |
| 112 | + cross build --target x86_64-unknown-linux-musl --release |
| 113 | +
|
| 114 | + - name: Fix Registry and Repository names |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + echo "REGISTRY=$(echo $REGISTRY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 118 | + echo "IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 119 | +
|
| 120 | + - name: Build and push Docker image for amd64 |
| 121 | + id: build_and_push |
| 122 | + uses: docker/build-push-action@v5 |
| 123 | + with: |
| 124 | + context: . |
| 125 | + file: "configurable-streamer/Dockerfile.amd" |
| 126 | + push: true |
| 127 | + platforms: linux/amd64 |
| 128 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64-${{ github.sha }} |
| 129 | + labels: ${{ needs.setup.outputs.labels }} |
| 130 | + |
| 131 | + create-manifest: |
| 132 | + needs: [setup, build-arm64, build-amd64] |
| 133 | + runs-on: ubuntu-latest |
| 134 | + permissions: |
| 135 | + packages: write |
| 136 | + steps: |
| 137 | + - name: Login to the Container registry |
| 138 | + uses: docker/login-action@v3 |
| 139 | + with: |
| 140 | + registry: ${{ env.REGISTRY }} |
| 141 | + username: ${{ github.actor }} |
| 142 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + |
| 144 | + - name: Set up Docker Buildx |
| 145 | + uses: docker/setup-buildx-action@v3 |
| 146 | + |
| 147 | + - name: Fix Registry and Repository names |
| 148 | + shell: bash |
| 149 | + run: | |
| 150 | + echo "REGISTRY=$(echo $REGISTRY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 151 | + echo "IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 152 | +
|
| 153 | + - name: Create and push manifest |
| 154 | + shell: bash |
| 155 | + run: | |
| 156 | + for tag in ${{ needs.setup.outputs.tags }}; do |
| 157 | + docker buildx imagetools create -t $tag \ |
| 158 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64-${{ github.sha }} \ |
| 159 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64-${{ github.sha }} |
| 160 | + done |
0 commit comments