diff --git a/.github/workflows/push-compare.yml b/.github/workflows/push-compare.yml index 5946166..7f29165 100644 --- a/.github/workflows/push-compare.yml +++ b/.github/workflows/push-compare.yml @@ -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 }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f0c3a86..da29841 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb9476a..418818d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: