|
| 1 | +# |
| 2 | +# Copyright (c) 2021-2025 Red Hat, Inc. |
| 3 | +# This program and the accompanying materials are made |
| 4 | +# available under the terms of the Eclipse Public License 2.0 |
| 5 | +# which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: EPL-2.0 |
| 8 | +# |
| 9 | + |
| 10 | +name: image-publish |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + tags: |
| 17 | + - '7.*.*' |
| 18 | + |
| 19 | +jobs: |
| 20 | + |
| 21 | + build: |
| 22 | + name: build |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + dist: [ 'musl', 'libc-ubi8', 'libc-ubi9' ] |
| 27 | + runners: ['ubuntu-22.04', 'ubuntu-22.04-arm'] |
| 28 | + runs-on: ${{matrix.runners}} |
| 29 | + steps: |
| 30 | + - name: Set arch environment variable |
| 31 | + run: | |
| 32 | + if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then |
| 33 | + echo arch="amd64" >> $GITHUB_ENV |
| 34 | + else |
| 35 | + echo arch="arm64" >> $GITHUB_ENV |
| 36 | + fi |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + - name: Docker Build |
| 40 | + env: |
| 41 | + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + run: | |
| 44 | + docker buildx build --memory-swap -1 --memory 10g --platform linux/${{env.arch}} -f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile --load -t linux-${{matrix.dist}}-${{env.arch}} . |
| 45 | + - name: Upload image |
| 46 | + |
| 47 | + with: |
| 48 | + image: "linux-${{matrix.dist}}-${{env.arch}}" |
| 49 | + |
| 50 | + assemble: |
| 51 | + name: assemble |
| 52 | + needs: build |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: |
| 56 | + runners: ['ubuntu-22.04', 'ubuntu-22.04-arm'] |
| 57 | + runs-on: ${{matrix.runners}} |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v4 |
| 61 | + - name: Set branch environment variable |
| 62 | + run: | |
| 63 | + BRANCH_NAME=${{ github.ref }} |
| 64 | + echo "BRANCH_NAME=${BRANCH_NAME##*/}" >> $GITHUB_ENV |
| 65 | + - name: Set arch environment variable |
| 66 | + run: | |
| 67 | + if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then |
| 68 | + echo arch="amd64" >> $GITHUB_ENV |
| 69 | + else |
| 70 | + echo arch="arm64" >> $GITHUB_ENV |
| 71 | + fi |
| 72 | + - name: Set tag suffix environment variable |
| 73 | + run: | |
| 74 | + SHORT_SHA1=$(git rev-parse --short=7 HEAD) |
| 75 | + if [[ ${{env.BRANCH_NAME}} == main ]]; then |
| 76 | + echo "tag_suffix=${SHORT_SHA1}" >> $GITHUB_ENV |
| 77 | + elif [[ ${{env.BRANCH_NAME}} =~ ^7\.[0-9]+\.[0-9]+$ ]]; then |
| 78 | + echo "tag_suffix=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV |
| 79 | + fi |
| 80 | + - name: Download linux-libc-ubi8-amd64 image |
| 81 | + |
| 82 | + with: |
| 83 | + image: "linux-libc-ubi8-${{env.arch}}" |
| 84 | + - name: Download linux-libc-ubi9-amd64 image |
| 85 | + |
| 86 | + with: |
| 87 | + image: "linux-libc-ubi9-${{env.arch}}" |
| 88 | + - name: Download linux-musl image |
| 89 | + |
| 90 | + with: |
| 91 | + image: "linux-musl-${{env.arch}}" |
| 92 | + - name: Display docker images |
| 93 | + run: docker images |
| 94 | + - name: Update assembly.Dockerfile |
| 95 | + run: | |
| 96 | + sed "s|FROM linux-libc-ubi8|FROM linux-libc-ubi8-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile" |
| 97 | + sed "s|FROM linux-libc-ubi9|FROM linux-libc-ubi9-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile" |
| 98 | + sed "s|FROM linux-musl|FROM linux-musl-${{env.arch}}|" -i "build/dockerfiles/assembly.Dockerfile" |
| 99 | + - name: Login to Quay.io |
| 100 | + uses: docker/login-action@v2 |
| 101 | + with: |
| 102 | + registry: quay.io |
| 103 | + username: ${{ secrets.QUAY_USERNAME }} |
| 104 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 105 | + - name: Assemble che-code |
| 106 | + run: | |
| 107 | + docker buildx build \ |
| 108 | + --platform linux/${{env.arch}} \ |
| 109 | + --progress=plain \ |
| 110 | + --push \ |
| 111 | + -f build/dockerfiles/assembly.Dockerfile \ |
| 112 | + -t quay.io/che-incubator/che-code:${{env.arch}}-${{env.tag_suffix}} . |
| 113 | +
|
| 114 | + publish: |
| 115 | + name: publish |
| 116 | + needs: assemble |
| 117 | + runs-on: ubuntu-22.04 |
| 118 | + steps: |
| 119 | + - name: Checkout |
| 120 | + uses: actions/checkout@v4 |
| 121 | + - name: Set branch environment variable |
| 122 | + run: | |
| 123 | + BRANCH_NAME=${{ github.ref }} |
| 124 | + echo "BRANCH_NAME=${BRANCH_NAME##*/}" >> $GITHUB_ENV |
| 125 | + - name: Set tag suffix environment variable |
| 126 | + run: | |
| 127 | + SHORT_SHA1=$(git rev-parse --short=7 HEAD) |
| 128 | + if [[ ${{env.BRANCH_NAME}} == main ]]; then |
| 129 | + echo "tag_suffix=${SHORT_SHA1}" >> $GITHUB_ENV |
| 130 | + elif [[ ${{env.BRANCH_NAME}} =~ ^7\.[0-9]+\.[0-9]+$ ]]; then |
| 131 | + echo "tag_suffix=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV |
| 132 | + fi |
| 133 | + - name: Login to Quay.io |
| 134 | + uses: docker/login-action@v2 |
| 135 | + with: |
| 136 | + registry: quay.io |
| 137 | + username: ${{ secrets.QUAY_USERNAME }} |
| 138 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 139 | + - name: publish |
| 140 | + run: | |
| 141 | + SHORT_SHA1=$(git rev-parse --short=7 HEAD) |
| 142 | + if [[ ${{env.BRANCH_NAME}} == main ]]; then |
| 143 | + docker manifest create quay.io/che-incubator/che-code:next --amend quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --amend quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} |
| 144 | + docker manifest annotate quay.io/che-incubator/che-code:next quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --os linux --arch amd64 |
| 145 | + docker manifest annotate quay.io/che-incubator/che-code:next quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} --os linux --arch arm64 |
| 146 | + docker manifest push quay.io/che-incubator/che-code:next |
| 147 | + |
| 148 | + docker manifest create quay.io/che-incubator/che-code:insiders --amend quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --amend quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} |
| 149 | + docker manifest annotate quay.io/che-incubator/che-code:insiders quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --os linux --arch amd64 |
| 150 | + docker manifest annotate quay.io/che-incubator/che-code:insiders quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} --os linux --arch arm64 |
| 151 | + docker manifest push quay.io/che-incubator/che-code:insiders |
| 152 | + |
| 153 | + docker manifest create quay.io/che-incubator/che-code:insiders-${SHORT_SHA1} --amend quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --amend quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} |
| 154 | + docker manifest annotate quay.io/che-incubator/che-code:insiders-${SHORT_SHA1} quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --os linux --arch amd64 |
| 155 | + docker manifest annotate quay.io/che-incubator/che-code:insiders-${SHORT_SHA1} quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} --os linux --arch arm64 |
| 156 | + docker manifest push quay.io/che-incubator/che-code:insiders-${SHORT_SHA1} |
| 157 | + elif [[ ${{env.BRANCH_NAME}} =~ ^7\.[0-9]+\.[0-9]+$ ]]; then |
| 158 | + docker manifest create quay.io/che-incubator/che-code:${{ env.BRANCH_NAME }} --amend quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --amend quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} |
| 159 | + docker manifest annotate quay.io/che-incubator/che-code:${{ env.BRANCH_NAME }} quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --os linux --arch amd64 |
| 160 | + docker manifest annotate quay.io/che-incubator/che-code:${{ env.BRANCH_NAME }} quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} --os linux --arch arm64 |
| 161 | + docker manifest push quay.io/che-incubator/che-code:${{ env.BRANCH_NAME }} |
| 162 | + |
| 163 | + docker manifest create quay.io/che-incubator/che-code:latest --amend quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --amend quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} |
| 164 | + docker manifest annotate quay.io/che-incubator/che-code:latest quay.io/che-incubator/che-code:amd64-${{env.tag_suffix}} --os linux --arch amd64 |
| 165 | + docker manifest annotate quay.io/che-incubator/che-code:latest quay.io/che-incubator/che-code:arm64-${{env.tag_suffix}} --os linux --arch arm64 |
| 166 | + docker manifest push quay.io/che-incubator/che-code:latest |
| 167 | + fi |
| 168 | +
|
| 169 | + release-finish: |
| 170 | + name: release-finish |
| 171 | + needs: [build, assemble, publish] |
| 172 | + runs-on: ubuntu-22.04 |
| 173 | + # don't notify for cancelled builds |
| 174 | + if: (success() || failure()) && github.ref != 'refs/heads/main' |
| 175 | + steps: |
| 176 | + - name: Set variables |
| 177 | + run: | |
| 178 | + BRANCH_NAME=${{ github.ref }} |
| 179 | + echo "BRANCH_NAME=${BRANCH_NAME##*/}" >> $GITHUB_ENV |
| 180 | +
|
| 181 | + dev: |
| 182 | + name: dev |
| 183 | + runs-on: ubuntu-22.04 |
| 184 | + if: github.ref == 'refs/heads/main' |
| 185 | + steps: |
| 186 | + - name: Checkout |
| 187 | + uses: actions/checkout@v4 |
| 188 | + - name: Login to Quay.io |
| 189 | + uses: docker/login-action@v2 |
| 190 | + with: |
| 191 | + registry: quay.io |
| 192 | + username: ${{ secrets.QUAY_USERNAME }} |
| 193 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 194 | + - name: Docker Build and Push |
| 195 | + env: |
| 196 | + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note |
| 197 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 198 | + run: | |
| 199 | + SHORT_SHA1=$(git rev-parse --short=7 HEAD) |
| 200 | + docker buildx build --platform linux/amd64 -f build/dockerfiles/dev.Dockerfile --push -t quay.io/che-incubator/che-code-dev:insiders -t quay.io/che-incubator/che-code-dev:next -t quay.io/che-incubator/che-code-dev:insiders-${SHORT_SHA1} . |
| 201 | + docker buildx build --platform linux/amd64 -f build/dockerfiles/dev.sshd.Dockerfile --push -t quay.io/che-incubator/che-code-sshd:insiders -t quay.io/che-incubator/che-code-sshd:next -t quay.io/che-incubator/che-code-sshd:insiders-${SHORT_SHA1} . |
| 202 | +
|
0 commit comments