Skip to content
Snippets Groups Projects
Commit ab6e4210 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

fix: reworked tag artefact retrieval process

Previously worked on supposition that all version were synched
(i.e. all aidge modules were on 0.3.xx at the same time).
This is not the case. This led to issue like this releas pipeline
https://gitlab.eclipse.org/eclipse/aidge/aidge_quantization/-/pipelines?page=1&scope=all&ref=v0.2.0
where version retrieved for core & backend cpu were 0.2.xx instead of 0.3.xx
parent 551db6da
No related branches found
No related tags found
No related merge requests found
...@@ -89,9 +89,6 @@ ...@@ -89,9 +89,6 @@
# CASE WHERE A COMMIT TAG IS CREATED # CASE WHERE A COMMIT TAG IS CREATED
elif [[ ! -z "$CI_COMMIT_TAG" ]]; then elif [[ ! -z "$CI_COMMIT_TAG" ]]; then
# retrieving data from current project # retrieving data from current project
TAG_MAJOR=$(echo "$CI_COMMIT_TAG" | awk -F'[v.]' '{print $2}')
TAG_MINOR=$(echo "$CI_COMMIT_TAG" | awk -F'[v.]' '{print $3}')
TAG_FIX=$(echo "$CI_COMMIT_TAG" | awk -F'[v.]' '{print $4}')
echo "Retrieving tags of $DEP_NAME via url $DEP_API_URL/repository/tags?per_page=100." echo "Retrieving tags of $DEP_NAME via url $DEP_API_URL/repository/tags?per_page=100."
DEP_TAGS=$(jq --slurp ' DEP_TAGS=$(jq --slurp '
.[] .[]
...@@ -103,29 +100,9 @@ ...@@ -103,29 +100,9 @@
echo "No tag found for $DEP_NAME at url $DEP_API_URL/repository/tags?per_page=100" echo "No tag found for $DEP_NAME at url $DEP_API_URL/repository/tags?per_page=100"
echo "Leaving early." echo "Leaving early."
exit 1 exit 1
fi
echo "Looking for latest fix release corresponding to minor release : v$TAG_MAJOR.$TAG_MINOR.*"
SELECTED_DEPS_TAGS=$(jq --arg major "$TAG_MAJOR" \
--arg minor "$TAG_MINOR" \
'map(select(.name | startswith("v\($major).\($minor).")))' <<< "$DEP_TAGS")
if [[ $(jq length <<< $SELECTED_DEPS_TAGS) == 0 ]]; then
echo "No release v$TAG_MAJOR.$TAG_MINOR.* found. Looking for latest minor release v$TAG_MAJOR.*.* in $DEP_NAME."
SELECTED_DEPS_TAGS=$(jq --arg major "$TAG_MAJOR" \
--arg minor "$TAG_MINOR" \
'map(select(.name | startswith("v\($major).\($minor).")))' <<< "$DEP_TAGS")
fi
if [[ $(jq length <<< $SELECTED_DEPS_TAGS) == 0 ]]; then
echo "No release v$TAG_MAJOR.$TAG_MINOR.* found. Looking for latest minor release v$TAG_MAJOR.*.* in $DEP_NAME."
SELECTED_DEPS_TAGS=$(jq --arg major "$TAG_MAJOR" \
'map(select(.name | startswith("v\($major).")))' <<< "$DEP_TAGS")
fi
if [[ $(jq length <<< $SELECTED_DEPS_TAGS) > 0 ]]; then
BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$SELECTED_DEPS_TAGS")
echo "Found a release with corresponding $BRANCH_TO_PULL"
else else
echo "No release v$TAG_MAJOR.*.* found. Simply retrieving latest release v*.*.* in $DEP_NAME."
BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$DEP_TAGS") BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$DEP_TAGS")
echo "Retrieving latest release tag : $BRANCH_TO_PULL in $DEP_NAME."
fi fi
echo "Found release : $BRANCH_TO_PULL. Using it as \$BRANCH_TO_PULL." echo "Found release : $BRANCH_TO_PULL. Using it as \$BRANCH_TO_PULL."
...@@ -362,29 +339,17 @@ ...@@ -362,29 +339,17 @@
###################################### ######################################
# CASE WHERE A COMMIT TAG IS CREATED # CASE WHERE A COMMIT TAG IS CREATED
} elseif ( "$CI_COMMIT_TAG" ) { } elseif ( "$CI_COMMIT_TAG" ) {
$TAG_TUPLE=$($CI_COMMIT_TAG -replace "v","").Split(".")
Write-Host "Retrieving repo tags from $DEP_API_URL/repository/tags?per_page=100" Write-Host "Retrieving repo tags from $DEP_API_URL/repository/tags?per_page=100"
$DEP_TAGS = $($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) | $DEP_TAGS = $($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) |
Sort-Object -Property {[datetime]$_.commit.created_at} -Descending) Sort-Object -Property {[datetime]$_.commit.created_at} -Descending)
if ( $DEP_TAGS.Count -eq 0 ) {
Write-Host "Looking for latest fix release the corressponds to $CI_PROJECT_NAME minor: v$($TAG_TUPLE[0]).$($TAG_TUPLE[1]).*" Write-Host "No tag found for $DEP_NAME at url $DEP_API_URL/repository/tags?per_page=100"
$SELECTED_TAGS = $DEP_TAGS | Where-Object { $_.name -like "v$($TAG_TUPLE[0]).$($TAG_TUPLE[1]).*" } Write-Host "Leaving early."
$SELECTED_TAGS = @($SELECTED_TAGS) exit 1
$SELECTED_TAGS | Out-String } else {
if ( $SELECTED_TAGS.Count -eq 0 ) { $BRANCH_TO_PULL=$DEP_TAGS[0].name
Write-Host "No fix release found, looking for latest minor corresponding to $CI_PROJECT_NAME major : v$($TAG_TUPLE[0]).*.*" Write-Host "Retrieving latest available release : v$BRANCH_TO_PULL."
$SELECTED_TAGS = $DEP_TAGS | Where-Object { $_.name -like "v$($TAG_TUPLE[0]).*" }
$SELECTED_TAGS = @($SELECTED_TAGS)
}
if ( $SELECTED_TAGS.Count -gt 0 ) {
$BRANCH_TO_PULL=$SELECTED_TAGS[0].name
Write-Host "Found following release, $BRANCH_TO_PULL. Using it as BRANCH_TO_PULL."
} else {
Write-Host "Found no corresponding release corresponding to a major. Looking for latest available release : v*.*.* ."
$BRANCH_TO_PULL=$DEP_TAGS[0].name
Write-Host "Found following release, $BRANCH_TO_PULL. Using it as BRANCH_TO_PULL."
} }
########################################### ###########################################
# CASE CASUAL COMMIT or Draft MR PIPELINE # CASE CASUAL COMMIT or Draft MR PIPELINE
} else { } else {
......
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