...

Text file src/github.com/docker/cli/.github/workflows/build.yml

Documentation: github.com/docker/cli/.github/workflows

     1name: build
     2
     3concurrency:
     4  group: ${{ github.workflow }}-${{ github.ref }}
     5  cancel-in-progress: true
     6
     7env:
     8  VERSION: ${{ github.ref }}
     9
    10on:
    11  workflow_dispatch:
    12  push:
    13    branches:
    14      - 'master'
    15      - '[0-9]+.[0-9]+'
    16    tags:
    17      - 'v*'
    18  pull_request:
    19
    20jobs:
    21  prepare:
    22    runs-on: ubuntu-22.04
    23    outputs:
    24      matrix: ${{ steps.platforms.outputs.matrix }}
    25    steps:
    26      -
    27        name: Checkout
    28        uses: actions/checkout@v4
    29      -
    30        name: Create matrix
    31        id: platforms
    32        run: |
    33          echo "matrix=$(docker buildx bake cross --print | jq -cr '.target."cross".platforms')" >>${GITHUB_OUTPUT}
    34      -
    35        name: Show matrix
    36        run: |
    37          echo ${{ steps.platforms.outputs.matrix }}
    38
    39  build:
    40    runs-on: ubuntu-22.04
    41    needs:
    42      - prepare
    43    strategy:
    44      fail-fast: false
    45      matrix:
    46        target:
    47          - binary
    48          - dynbinary
    49        platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
    50        use_glibc:
    51          - ""
    52          - glibc
    53    steps:
    54      -
    55        name: Checkout
    56        uses: actions/checkout@v4
    57        with:
    58          fetch-depth: 0
    59      -
    60        name: Set up Docker Buildx
    61        uses: docker/setup-buildx-action@v3
    62      -
    63        name: Build
    64        uses: docker/bake-action@v4
    65        with:
    66          targets: ${{ matrix.target }}
    67          set: |
    68            *.platform=${{ matrix.platform }}
    69        env:
    70          USE_GLIBC: ${{ matrix.use_glibc }}
    71      -
    72        name: Create tarball
    73        working-directory: ./build
    74        run: |
    75          mkdir /tmp/out
    76          platform=${{ matrix.platform }}
    77          platformPair=${platform//\//-}
    78          tar -cvzf "/tmp/out/docker-${platformPair}.tar.gz" .
    79          if [ -z "${{ matrix.use_glibc }}" ]; then
    80            echo "ARTIFACT_NAME=${{ matrix.target }}" >> $GITHUB_ENV
    81          else
    82            echo "ARTIFACT_NAME=${{ matrix.target }}-glibc" >> $GITHUB_ENV
    83          fi
    84      -
    85        name: Upload artifacts
    86        uses: actions/upload-artifact@v3
    87        with:
    88          name: ${{ env.ARTIFACT_NAME }}
    89          path: /tmp/out/*
    90          if-no-files-found: error
    91
    92  bin-image:
    93    runs-on: ubuntu-22.04
    94    if: ${{ github.event_name != 'pull_request' && github.repository == 'docker/cli' }}
    95    steps:
    96      -
    97        name: Checkout
    98        uses: actions/checkout@v4
    99      -
   100        name: Set up QEMU
   101        uses: docker/setup-qemu-action@v3
   102      -
   103        name: Set up Docker Buildx
   104        uses: docker/setup-buildx-action@v3
   105      -
   106        name: Docker meta
   107        id: meta
   108        uses: docker/metadata-action@v5
   109        with:
   110          images: dockereng/cli-bin
   111          tags: |
   112            type=semver,pattern={{version}}
   113            type=ref,event=branch
   114            type=ref,event=pr
   115            type=sha
   116      -
   117        name: Login to DockerHub
   118        if: github.event_name != 'pull_request'
   119        uses: docker/login-action@v3
   120        with:
   121          username: ${{ secrets.DOCKERHUB_CLIBIN_USERNAME }}
   122          password: ${{ secrets.DOCKERHUB_CLIBIN_TOKEN }}
   123      -
   124        name: Build and push image
   125        uses: docker/bake-action@v4
   126        with:
   127          files: |
   128            ./docker-bake.hcl
   129            ${{ steps.meta.outputs.bake-file }}
   130          targets: bin-image-cross
   131          push: ${{ github.event_name != 'pull_request' }}
   132          set: |
   133            *.cache-from=type=gha,scope=bin-image
   134            *.cache-to=type=gha,scope=bin-image,mode=max
   135
   136  prepare-plugins:
   137    runs-on: ubuntu-22.04
   138    outputs:
   139      matrix: ${{ steps.platforms.outputs.matrix }}
   140    steps:
   141      -
   142        name: Checkout
   143        uses: actions/checkout@v4
   144      -
   145        name: Create matrix
   146        id: platforms
   147        run: |
   148          echo "matrix=$(docker buildx bake plugins-cross --print | jq -cr '.target."plugins-cross".platforms')" >>${GITHUB_OUTPUT}
   149      -
   150        name: Show matrix
   151        run: |
   152          echo ${{ steps.platforms.outputs.matrix }}
   153
   154  plugins:
   155    runs-on: ubuntu-22.04
   156    needs:
   157      - prepare-plugins
   158    strategy:
   159      fail-fast: false
   160      matrix:
   161        platform: ${{ fromJson(needs.prepare-plugins.outputs.matrix) }}
   162    steps:
   163      -
   164        name: Checkout
   165        uses: actions/checkout@v4
   166      -
   167        name: Set up Docker Buildx
   168        uses: docker/setup-buildx-action@v3
   169      -
   170        name: Build
   171        uses: docker/bake-action@v4
   172        with:
   173          targets: plugins-cross
   174          set: |
   175            *.platform=${{ matrix.platform }}

View as plain text