Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit fc228fe2 authored by Dorian Turba's avatar Dorian Turba
Browse files

fix: missing tags from docker api

parent d538faed
Branches 10-fix-eslint-config
No related tags found
No related merge requests found
include: include:
- remote: 'https://gitlab.com/swepy/cicd-templates/docker-build/-/raw/0.2.0/templates/docker-build.yml' - remote: 'https://gitlab.com/swepy/cicd-templates/docker-build/-/raw/0.2.0/templates/docker-build.yml'
- remote: 'https://gitlab.com/swepy/cicd-templates/release-by-changelog/-/raw/0.4.2/templates/release-by-changelog.yml' - remote: 'https://gitlab.com/swepy/cicd-templates/release-by-changelog/-/raw/0.4.2/templates/release-by-changelog.yml'
- remote: 'https://gitlab.com/swepy/cicd-templates/pypi-to-docker-missing-version/-/raw/0.2.0/templates/pypi-to-docker-missing-version.yml'
release_by_changelog: release_by_changelog:
rules: rules:
- if: '$CI_PIPELINE_SOURCE != "pipeline" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - if: '$CI_PIPELINE_SOURCE != "pipeline" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
next_version: pypi-to-docker-missing-version:
stage: build
image: alpine:latest
variables: variables:
PACKAGE_NAME: ruff
IMAGE_NAME: swepy/ruff IMAGE_NAME: swepy/ruff
script: PACKAGE_NAME: ruff
#!/bin/bash TAGS: 0.0.44 0.0.43 0.0.42 0.0.40 0.0.39 0.0.37 0.0.36 0.0.35 0.0.34 0.0.33 0.0.32 0.0.31 0.0.30 0.0.29 0.0.28 0.0.25 0.0.24 0.0.23 0.0.22 0.0.21 0.0.20 0.0.19 0.0.18 0.0.17 0.0.16 0.0.15 0.0.14 0.0.13
- apk update
- apk add --no-cache curl jq
# get docker tags
- echo "Image name=$IMAGE_NAME"
- docker_url="https://registry.hub.docker.com/v2/repositories/$IMAGE_NAME/tags"
- tags=""
# get all tags
- while [ -n "$docker_url" ]; do
- docker_response=$(curl -s "$docker_url")
- if [ "$(echo "$docker_response" | jq -r '.results | length')" -eq 0 ]; then
- break
- fi
- tags="$tags $(echo "$docker_response" | jq -r '.results[].name')"
- docker_url=$(echo "$docker_response" | jq -r '.next')
- if [ "$docker_url" = "null" ]; then
- docker_url=""
- fi
- done
- echo "tags on docker=$tags"
# pypi
- pypi_url="https://pypi.org/pypi/$PACKAGE_NAME/json"
- pypi_response=$(curl -s "$pypi_url")
- releases=$(echo "$pypi_response" | jq -r '.releases | keys[]')
- echo "releases on pypi:"
- printf "%s " $releases
# find missing releases
- missing_releases=""
- eval 'for release in $releases; do found=0; for tag in $tags; do if [ "$release" = "$tag" ]; then found=1; break; fi; done; if [ $found -eq 0 ]; then missing_releases="$missing_releases $release"; fi; done'
- missing_releases=$(echo $missing_releases)
- echo "missing tags=$missing_releases"
# regex pattern for versioning (adjust if needed)
#regex='^[0-9]+(\.[0-9]+)*$'
- regex='^((0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*))(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
- sorted_releases=$(printf "%s\n" $missing_releases | grep -E "$regex" | sort -t. -k1,1n -k2,2n -k3,3n)
# print the sorted versions
- echo "Sorted releases:"
- printf "%s " $sorted_releases
- version_to_publish=$(echo $sorted_releases | awk '{print $1}')
- 'echo "Version to publish: $version_to_publish"'
- echo "$version_to_publish" > version.txt
- cat version.txt
artifacts:
name: "version"
paths:
- version.txt
expire_in: 1 day
rules: rules:
- if: $CI_PIPELINE_SOURCE == "pipeline" - if: $CI_PIPELINE_SOURCE == "pipeline"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment