Skip to content

Commit

Permalink
chore: update docker tags 🐳 (#4347)
Browse files Browse the repository at this point in the history
* chore: update docker tags 🐳

* chore: add version to network name

* fix: typo
  • Loading branch information
ahasna authored Dec 13, 2023
1 parent fea5d05 commit cc72e2f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/_24_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@ jobs:
run: |
echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
echo "time=$(date +'%H:%M:%S')" >> "$GITHUB_OUTPUT"
get-version-from-branch-name:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout 🏁
uses: actions/checkout@v3
- name: Get version from branch name
id: version
run: |
version=$(./ci/scripts/extract_version.sh ${{ github.ref }})
echo "Extracted version: $version"
if [[ "$version" == "" ]]; then
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
else
echo "version=$version" >> "$GITHUB_OUTPUT"
fi
set-dockerfile-name:
runs-on: ubuntu-22.04
outputs:
Expand All @@ -54,7 +70,7 @@ jobs:
fi
private-images:
needs: [get-date-time, set-dockerfile-name]
needs: [get-date-time, set-dockerfile-name, get-version-from-branch-name]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -98,7 +114,8 @@ jobs:
type=raw,value=${{ github.sha }}
type=raw,value=${{ inputs.network }}
type=ref,event=branch
type=ref,event=tag
type=ref,event=tag,prefix=${{ inputs.network }}-
type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }},prefix=${{ inputs.network }}-,enable=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }}
type=ref,event=pr
- name: Login to Github Container Registry 🔑
Expand Down Expand Up @@ -140,7 +157,7 @@ jobs:

public-images:
if: inputs.publish_public_images || inputs.save_tags != ''
needs: [get-date-time, set-dockerfile-name]
needs: [get-date-time, set-dockerfile-name, get-version-from-branch-name]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -181,7 +198,8 @@ jobs:
type=raw,value=${{ github.sha }}
type=raw,value=${{ inputs.network }}
type=ref,event=branch
type=ref,event=tag
type=ref,event=tag,prefix=${{ inputs.network }}-
type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }},prefix=${{ inputs.network }}-,enable=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }}
type=ref,event=pr
- name: Login to DockerHub 🔑
Expand Down
20 changes: 15 additions & 5 deletions ci/scripts/extract_version.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#!/usr/bin/env bash

# Remove any prefixes like "v" from the tag
tag="${1#v}"
# Input string
input_string="$1"

# Extract major and minor version using cut command
version=$(echo "$tag" | cut -d. -f1,2)
# Regular expression to match version pattern (X.Y.Z or X.Y)
# This pattern looks for numbers separated by dots.
# The -E flag is used for extended regex, and -o to output only the matched part.
version=$(echo "$input_string" | grep -Eo '[0-9]+\.[0-9]+(\.[0-9]+)?')

# Check if a version was found
if [[ -z "$version" ]]; then
exit 0
fi

# Extract major and minor version
major_minor=$(echo "$version" | cut -d. -f1,2)

# Output the major and minor version
echo "$version"
echo "$major_minor"

0 comments on commit cc72e2f

Please sign in to comment.