From 393e89783a4e5b8ce888c8ada309e161c54bacef Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Mon, 15 Sep 2025 15:42:01 +0300 Subject: [PATCH 1/4] ci : create git tags for released docker images When releasing a docker image for build number X, we should also create the corresponding git tag. This allows users to easily checkout the corresponding source tree for given docker image. --- .github/workflows/docker.yml | 48 +++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2067927be56ca..5ffaa0ee00c04 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,22 +67,19 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Determine tag name + - name: Determine source tag name + id: srctag + uses: ./.github/actions/get-tag-name + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + + - name: Determine image tag name id: tag shell: bash run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" REPO_OWNER="${GITHUB_REPOSITORY_OWNER@L}" # to lower case REPO_NAME="${{ github.event.repository.name }}" - # determine tag name postfix (build number, commit hash) - if [[ "${{ env.GITHUB_BRANCH_NAME }}" == "master" ]]; then - TAG_POSTFIX="-b${BUILD_NUMBER}" - else - SAFE_NAME=$(echo "${{ env.GITHUB_BRANCH_NAME }}" | tr '/' '-') - TAG_POSTFIX="-${SAFE_NAME}-${SHORT_HASH}" - fi # list all tags possible if [[ "${{ matrix.config.tag }}" == "cpu" ]]; then TYPE="" @@ -90,9 +87,9 @@ jobs: TYPE="-${{ matrix.config.tag }}" fi PREFIX="ghcr.io/${REPO_OWNER}/${REPO_NAME}:" - FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}${TAG_POSTFIX}" - LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}${TAG_POSTFIX}" - SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}${TAG_POSTFIX}" + FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}${{ steps.srctag.outputs.name }}" + LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}${{ steps.srctag.outputs.name }}" + SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}${{ steps.srctag.outputs.name }}" echo "full_output_tags=$FULLTAGS" >> $GITHUB_OUTPUT echo "light_output_tags=$LIGHTTAGS" >> $GITHUB_OUTPUT echo "server_output_tags=$SERVERTAGS" >> $GITHUB_OUTPUT @@ -100,7 +97,6 @@ jobs: echo "light_output_tags=$LIGHTTAGS" # print out for debugging echo "server_output_tags=$SERVERTAGS" # print out for debugging env: - GITHUB_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}' - name: Free Disk Space (Ubuntu) @@ -176,3 +172,27 @@ jobs: # return to this if the experimental github cache is having issues #cache-to: type=local,dest=/tmp/.buildx-cache #cache-from: type=local,src=/tmp/.buildx-cache + + create_tag: + name: Create and push git tag + runs-on: ubuntu-22.04 + + steps: + - name: Clone + id: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Determine source tag name + id: srctag + uses: ./.github/actions/get-tag-name + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name } + + - name: Create and push git tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git tag ${{ steps.srctag.outputs.name }} || exit 0 + git push origin ${{ steps.srctag.outputs.name }} || exit 0 From 6c7386acb8579a54d2c016ad359dfb57fe73fef8 Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Thu, 25 Sep 2025 13:43:14 +0000 Subject: [PATCH 2/4] Update .github/workflows/docker.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sigbjørn Skjæret --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5ffaa0ee00c04..4b8b540435293 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -188,7 +188,7 @@ jobs: id: srctag uses: ./.github/actions/get-tag-name env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name } + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - name: Create and push git tag env: From 66b0981de161e888116ec1701b366004e35df4ec Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Thu, 25 Sep 2025 13:53:06 +0000 Subject: [PATCH 3/4] Update .github/workflows/docker.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sigbjørn Skjæret --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4b8b540435293..eb1ae4d8ce854 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -87,9 +87,9 @@ jobs: TYPE="-${{ matrix.config.tag }}" fi PREFIX="ghcr.io/${REPO_OWNER}/${REPO_NAME}:" - FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}${{ steps.srctag.outputs.name }}" - LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}${{ steps.srctag.outputs.name }}" - SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}${{ steps.srctag.outputs.name }}" + FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}-${{ steps.srctag.outputs.name }}" + LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}-${{ steps.srctag.outputs.name }}" + SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}-${{ steps.srctag.outputs.name }}" echo "full_output_tags=$FULLTAGS" >> $GITHUB_OUTPUT echo "light_output_tags=$LIGHTTAGS" >> $GITHUB_OUTPUT echo "server_output_tags=$SERVERTAGS" >> $GITHUB_OUTPUT From 008f81592cb116d5db327e35eab06d0b50fd4104 Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Fri, 26 Sep 2025 07:13:22 +0000 Subject: [PATCH 4/4] Apply suggestion from @CISC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sigbjørn Skjæret --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index eb1ae4d8ce854..708d96de84e5f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -176,6 +176,8 @@ jobs: create_tag: name: Create and push git tag runs-on: ubuntu-22.04 + permissions: + contents: write steps: - name: Clone