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 717b0acb authored by Dorian Turba's avatar Dorian Turba
Browse files

Merge branch 'trunk'

parents 23e8bf14 837a5790
No related branches found
No related tags found
No related merge requests found
Pipeline #38203 passed
[tool.bumpversion]
commit = true
current_version = "2.0.0"
current_version = "0.1.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
replace = "{new_version}"
search = "{current_version}"
......@@ -13,7 +13,19 @@ tag = false
filename = "CHANGELOG.md"
replace = """## [Unreleased]
[![Pipeline](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/badges/trunk/pipeline.svg)](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/-/pipelines?ref=trunk)
## [{new_version}] - {now:%Y-%m-%d}
[![Pipeline](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/badges/{new_version}/pipeline.svg)](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/-/pipelines?ref={new_version})
"""
search = """## [Unreleased]
[![Pipeline](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/badges/trunk/pipeline.svg)](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/-/pipelines?ref=trunk)
"""
[[tool.bumpversion.files]]
allow-dirty = true
filename = "README.md"
replace = "{new_version}"
search = "{current_version}"
......@@ -2,3 +2,11 @@ include:
- project: 'swepy/cicd-templates/release-by-changelog'
ref: '0.4.2'
file: 'templates/release-by-changelog.yml'
- project: 'swepy/cicd-templates/pypi-to-docker-missing-version'
ref: 'trunk'
file: 'templates/pypi-to-docker-missing-version.yml'
pypi_to_docker_missing_version:
variables:
PACKAGE_NAME: ruff
IMAGE_NAME: swepy/ruff
......@@ -7,4 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
[![Pipeline](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/badges/trunk/pipeline.svg)](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/-/pipelines?ref=trunk)
## [0.1.0] - 2024-06-26
[![Pipeline](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/badges/0.1.0/pipeline.svg)](https://lab.frogg.it/swepy/cicd-templates/pypi-to-docker-missing-version/-/pipelines?ref=0.1.0)
* Initial version
......@@ -19,7 +19,7 @@ As a remote Template (recommended):
```yaml
include:
- remote: 'https://gitlab.com/swepy/cicd-templates/pypi-to-docker-missing-version/-/raw/0.0.0/templates/pypi-to-docker-missing-version.yml'
- remote: 'https://gitlab.com/swepy/cicd-templates/pypi-to-docker-missing-version/-/raw/0.1.0/templates/pypi-to-docker-missing-version.yml'
```
As a local Template (if the template is local to the instance):
......@@ -27,7 +27,7 @@ As a local Template (if the template is local to the instance):
```yaml
include:
- project: 'swepy/cicd-templates/pypi-to-docker-missing-version'
ref: '0.0.0'
ref: '0.1.0'
file: 'templates/pypi-to-docker-missing-version.yml'
```
......@@ -36,7 +36,7 @@ component is local to the instance):
```yaml
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/pypi-to-docker-missing-version/pypi-to-docker-missing-version@0.2.0
- component: $CI_SERVER_FQDN/swepy/cicd-templates/pypi-to-docker-missing-version/pypi-to-docker-missing-version@0.1.0
```
### Customize job
......
pypi_to_docker_missing_version:
stage: build
image: alpine:latest
variables:
IMAGE_NAME: ""
PACKAGE_INDEX_API_URL: https://pypi.org/pypi
PACKAGE_NAME: $CI_PROJECT_NAME
REPOSITORIES_API_URL: https://registry.hub.docker.com/v2/repositories
SORT_CMD: sort -V
TAGS: ""
script:
#!/bin/bash
- apk update
- apk add --no-cache curl jq
# get docker tags
- echo "Image name=$IMAGE_NAME"
- docker_url="$REPOSITORIES_API_URL/$IMAGE_NAME/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="$PACKAGE_INDEX_API_URL/$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)
# sorted_releases=$(printf "%s\n" $missing_releases | grep -E "$regex" | sort -t. -k1,1n -k2,2n -k3,3n)
# templated version is simpler
- sorted_releases=$(printf "%s\n" $missing_releases | $SORT_CMD)
# 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
\ No newline at end of file
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