|
| 1 | +# Copyright (c) 2023 Robert Bosch GmbH |
| 2 | +# |
| 3 | +# This program and the accompanying materials are made available under the |
| 4 | +# terms of the Apache License, Version 2.0 which is available at |
| 5 | +# https://www.apache.org/licenses/LICENSE-2.0. |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | +# |
| 13 | +# SPDX-License-Identifier: Apache-2.0 |
| 14 | + |
| 15 | +name: Release |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + tags: |
| 20 | + - 'v[0-9]+\.[0-9]+\.[0-9]+' |
| 21 | + |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +jobs: |
| 25 | + wait-for-images: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + name: Wait for container images |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Wait for build-base-images workflow to succeed |
| 31 | + uses: fountainhead/[email protected] |
| 32 | + with: |
| 33 | + checkName: Building image |
| 34 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + timeoutSeconds: 5400 |
| 36 | + intervalSeconds: 120 |
| 37 | + |
| 38 | + initialize-matrix: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + name: Setting up build matrix |
| 41 | + needs: [wait-for-images] |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Login to GitHub Container Registry |
| 45 | + uses: docker/login-action@v2 |
| 46 | + with: |
| 47 | + registry: ghcr.io |
| 48 | + username: ${{ github.repository_owner }} |
| 49 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + |
| 51 | + - id: github-repository-name-case-adjusted |
| 52 | + name: Prepare repository name in lower case for docker upload. |
| 53 | + uses: ASzc/change-string-case-action@v5 |
| 54 | + with: |
| 55 | + string: ${{ github.repository }} |
| 56 | + |
| 57 | + - uses: docker/setup-buildx-action@v2 |
| 58 | + id: buildx |
| 59 | + with: |
| 60 | + install: true |
| 61 | + |
| 62 | + - name: Get version from tag |
| 63 | + id: getVersions |
| 64 | + run: | |
| 65 | + semantic_version=$(sed -e "s/^v//" <<< ${{ github.ref_name }}) |
| 66 | + major_version=$(cut -d '.' -f 1 <<< "$semantic_version") |
| 67 | + major_minor_version=$(cut -d '.' -f 1,2 <<< "$semantic_version") |
| 68 | + echo "semantic_version=v$semantic_version" >> $GITHUB_OUTPUT |
| 69 | + echo "major_version=v$major_version" >> $GITHUB_OUTPUT |
| 70 | + echo "major_minor_version=v$major_minor_version" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + - name: Tag docker images |
| 73 | + run: | |
| 74 | + FQ_IMAGE_NAME=ghcr.io/${{ steps.github-repository-name-case-adjusted.outputs.lowercase }}/app-builder |
| 75 | + OLD_TAG=${{ github.sha }} |
| 76 | + V_XXX=${{ steps.getVersions.outputs.semantic_version }} |
| 77 | + V_X=${{ steps.getVersions.outputs.major_version }} |
| 78 | + V_XX=${{ steps.getVersions.outputs.major_minor_version }} |
| 79 | +
|
| 80 | + if [[ $V_XX != "v0.0" ]] ; then |
| 81 | + docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_XX $FQ_IMAGE_NAME:$OLD_TAG |
| 82 | + if [[ $V_X != "v0" ]] ; then |
| 83 | + docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_X $FQ_IMAGE_NAME:$OLD_TAG |
| 84 | + fi |
| 85 | + fi |
| 86 | +
|
| 87 | + docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_XXX $FQ_IMAGE_NAME:$OLD_TAG |
0 commit comments