Skip to content

Commit

Permalink
Change: Rework tag check (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalholthaus authored Nov 15, 2024
1 parent 07091a9 commit 5b9510a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
37 changes: 27 additions & 10 deletions .github/workflows/push-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,42 @@ jobs:
id: version
shell: bash
run: |
set +e
# Get latest minor version from dockerhub
dt="$(echo -e '${{ steps.dtags.outputs.output }}' | grep -E '${{ inputs.postgres-major-version }}.[0-9]+$' | sort -Vr | sed q)"
dt="$(echo -e '${{ steps.dtags.outputs.output }}' | grep -E '^${{ inputs.postgres-major-version }}.[0-9]+$' | sort -Vr | sed q)"
echo "New postgres version on dockerhub: $dt"
if ! [ "$dt" ]; then
echo 'No postgres release in dockerhub found for ${{ inputs.postgres-major-version }}'
echo 'No postgres release on dockerhub found for major version: ${{ inputs.postgres-major-version }}'
exit 1
fi
IFS='.' read -r -a dv <<< "$dt"
minor="${dv[1]}"
if ! [ "$minor" ]; then
echo "No postgres minor version found on dockerhub: $dt"
exit 2
fi
echo "New minor version: $minor"
# Get the latest tag filtered by postgres major version.
t="$(echo -e '${{ steps.tags.outputs.output }}' | grep -E "${{ inputs.postgres-major-version }}.$minor.[0-9]+$" | sort -Vr | sed q)"
if ! [ "$t" ]; then
t="${{ inputs.postgres-major-version }}.$minor.0"
t="$(echo -e '${{ steps.tags.outputs.output }}' | grep -E "^${{ inputs.postgres-major-version }}.$minor.[0-9]+$" | sort -Vr | sed q)"
if [ "$t" ]; then
echo "Current opensight-postgres version: $t"
# Increment patch level
IFS='.' read -r -a v <<< "$t"
if ! [ -v v[2] ]; then
echo "No patch level found in opensearch-postgres version: $t"
exit 3
fi
patch=$((v[2] + 1))
version="${{ inputs.postgres-major-version }}.$minor.$patch"
else
echo "New minor postgres version found on dockerhub: ${{ inputs.postgres-major-version }}.$minor"
version="${{ inputs.postgres-major-version }}.$minor.0"
fi
# Increment patch level
IFS='.' read -r -a v <<< "$t"
v[2]=$((v[2] + 1))
echo "output=v$(IFS="."; echo "${v[*]// /}")" >> $GITHUB_OUTPUT
echo "New opensight-postgres version: $version"
echo "output=$version" >> $GITHUB_OUTPUT
outputs:
compare: ${{ steps.compare.outputs.output }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
image-tags: |
type=raw,value=${{ inputs.postgres-major-version }}
type=raw,value=${{ inputs.version }}
type=raw,value=v${{ inputs.version }}
registry: ${{ vars.GREENBONE_REGISTRY }}
registry-username: ${{ secrets.GREENBONE_REGISTRY_USER }}
registry-password: ${{ secrets.GREENBONE_REGISTRY_TOKEN }}
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ jobs:
id: version
shell: bash
run: |
set +e
# Get latest minor version from dockerhub
dt="$(echo -e '${{ steps.dtags.outputs.output }}' | grep -E '${{ inputs.postgres-major-version }}.[0-9]+$' | sort -Vr | sed q)"
dt="$(echo -e '${{ steps.dtags.outputs.output }}' | grep -E '^${{ inputs.postgres-major-version }}.[0-9]+$' | sort -Vr | sed q)"
if ! [ "$dt" ]; then
echo "No minor found!"
echo "No version found on dockerhub for postgres: ${{ inputs.postgres-major-version }}"
exit 1
fi
IFS='.' read -r -a dv <<< "$dt"
minor="${dv[1]}"
if ! [ "$minor" ]; then
echo "No minor version found on dockerhub for postgres: $dt"
exit 2
fi
echo "output=${{ inputs.postgres-major-version }}.$minor.0" >> $GITHUB_OUTPUT
outputs:
Expand Down

0 comments on commit 5b9510a

Please sign in to comment.