Skip to content

Commit a4823d7

Browse files
rgerganovCISC
authored andcommitted
ci : create git tags for released docker images (ggml-org#16008)
* 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. * Update .github/workflows/docker.yml Co-authored-by: Sigbjørn Skjæret <[email protected]> * Update .github/workflows/docker.yml Co-authored-by: Sigbjørn Skjæret <[email protected]> * Apply suggestion from @CISC Co-authored-by: Sigbjørn Skjæret <[email protected]> --------- Co-authored-by: Sigbjørn Skjæret <[email protected]>
1 parent f0887ca commit a4823d7

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

.github/workflows/docker.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,36 @@ jobs:
6868
username: ${{ github.repository_owner }}
6969
password: ${{ secrets.GITHUB_TOKEN }}
7070

71-
- name: Determine tag name
71+
- name: Determine source tag name
72+
id: srctag
73+
uses: ./.github/actions/get-tag-name
74+
env:
75+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
76+
77+
- name: Determine image tag name
7278
id: tag
7379
shell: bash
7480
run: |
75-
BUILD_NUMBER="$(git rev-list --count HEAD)"
76-
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
7781
REPO_OWNER="${GITHUB_REPOSITORY_OWNER@L}" # to lower case
7882
REPO_NAME="${{ github.event.repository.name }}"
7983
80-
# determine tag name postfix (build number, commit hash)
81-
if [[ "${{ env.GITHUB_BRANCH_NAME }}" == "master" ]]; then
82-
TAG_POSTFIX="-b${BUILD_NUMBER}"
83-
else
84-
SAFE_NAME=$(echo "${{ env.GITHUB_BRANCH_NAME }}" | tr '/' '-')
85-
TAG_POSTFIX="-${SAFE_NAME}-${SHORT_HASH}"
86-
fi
8784
# list all tags possible
8885
if [[ "${{ matrix.config.tag }}" == "cpu" ]]; then
8986
TYPE=""
9087
else
9188
TYPE="-${{ matrix.config.tag }}"
9289
fi
9390
PREFIX="ghcr.io/${REPO_OWNER}/${REPO_NAME}:"
94-
FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}${TAG_POSTFIX}"
95-
LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}${TAG_POSTFIX}"
96-
SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}${TAG_POSTFIX}"
91+
FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}-${{ steps.srctag.outputs.name }}"
92+
LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPE}-${{ steps.srctag.outputs.name }}"
93+
SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}-${{ steps.srctag.outputs.name }}"
9794
echo "full_output_tags=$FULLTAGS" >> $GITHUB_OUTPUT
9895
echo "light_output_tags=$LIGHTTAGS" >> $GITHUB_OUTPUT
9996
echo "server_output_tags=$SERVERTAGS" >> $GITHUB_OUTPUT
10097
echo "full_output_tags=$FULLTAGS" # print out for debugging
10198
echo "light_output_tags=$LIGHTTAGS" # print out for debugging
10299
echo "server_output_tags=$SERVERTAGS" # print out for debugging
103100
env:
104-
GITHUB_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
105101
GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}'
106102

107103
- name: Free Disk Space (Ubuntu)
@@ -177,3 +173,29 @@ jobs:
177173
# return to this if the experimental github cache is having issues
178174
#cache-to: type=local,dest=/tmp/.buildx-cache
179175
#cache-from: type=local,src=/tmp/.buildx-cache
176+
177+
create_tag:
178+
name: Create and push git tag
179+
runs-on: ubuntu-22.04
180+
permissions:
181+
contents: write
182+
183+
steps:
184+
- name: Clone
185+
id: checkout
186+
uses: actions/checkout@v4
187+
with:
188+
fetch-depth: 0
189+
190+
- name: Determine source tag name
191+
id: srctag
192+
uses: ./.github/actions/get-tag-name
193+
env:
194+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
195+
196+
- name: Create and push git tag
197+
env:
198+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199+
run: |
200+
git tag ${{ steps.srctag.outputs.name }} || exit 0
201+
git push origin ${{ steps.srctag.outputs.name }} || exit 0

0 commit comments

Comments
 (0)