mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Merge #3207
3207: Add release check when starting latest CI r=Kerollmops a=curquiza Adding this to have the same kind of check before starting to move the latest tag <img width="737" alt="Capture d’écran 2022-12-07 à 12 18 33" src="https://user-images.githubusercontent.com/20380692/206165868-18a2be7c-78ec-48c9-acb9-d7f60797c2e3.png"> Also, removing an un-unused script Co-authored-by: curquiza <clementine@meilisearch.com>
This commit is contained in:
commit
34c0f11c26
132
.github/scripts/is-latest-release.sh
vendored
132
.github/scripts/is-latest-release.sh
vendored
@ -1,132 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Was used in our CIs to publish the latest docker image. Not used anymore, will be used again when v1 and v2 will be out and we will want to maintain multiple stable versions.
|
|
||||||
# Returns "true" or "false" (as a string) to be used in the `if` in GHA
|
|
||||||
|
|
||||||
# Checks if the current tag should be the latest (in terms of semver and not of release date).
|
|
||||||
# Ex: previous tag -> v2.1.1
|
|
||||||
# new tag -> v1.20.3
|
|
||||||
# The new tag (v1.20.3) should NOT be the latest
|
|
||||||
# So it returns "false", the `latest` tag should not be updated for the release v1.20.3 and still need to correspond to v2.1.1
|
|
||||||
|
|
||||||
# GLOBAL
|
|
||||||
GREP_SEMVER_REGEXP='v\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)$' # i.e. v[number].[number].[number]
|
|
||||||
|
|
||||||
# FUNCTIONS
|
|
||||||
|
|
||||||
# semverParseInto and semverLT from https://github.com/cloudflare/semver_bash/blob/master/semver.sh
|
|
||||||
|
|
||||||
# usage: semverParseInto version major minor patch special
|
|
||||||
# version: the string version
|
|
||||||
# major, minor, patch, special: will be assigned by the function
|
|
||||||
semverParseInto() {
|
|
||||||
local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
|
|
||||||
#MAJOR
|
|
||||||
eval $2=`echo $1 | sed -e "s#$RE#\1#"`
|
|
||||||
#MINOR
|
|
||||||
eval $3=`echo $1 | sed -e "s#$RE#\2#"`
|
|
||||||
#MINOR
|
|
||||||
eval $4=`echo $1 | sed -e "s#$RE#\3#"`
|
|
||||||
#SPECIAL
|
|
||||||
eval $5=`echo $1 | sed -e "s#$RE#\4#"`
|
|
||||||
}
|
|
||||||
|
|
||||||
# usage: semverLT version1 version2
|
|
||||||
semverLT() {
|
|
||||||
local MAJOR_A=0
|
|
||||||
local MINOR_A=0
|
|
||||||
local PATCH_A=0
|
|
||||||
local SPECIAL_A=0
|
|
||||||
|
|
||||||
local MAJOR_B=0
|
|
||||||
local MINOR_B=0
|
|
||||||
local PATCH_B=0
|
|
||||||
local SPECIAL_B=0
|
|
||||||
|
|
||||||
semverParseInto $1 MAJOR_A MINOR_A PATCH_A SPECIAL_A
|
|
||||||
semverParseInto $2 MAJOR_B MINOR_B PATCH_B SPECIAL_B
|
|
||||||
|
|
||||||
if [ $MAJOR_A -lt $MAJOR_B ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ $MAJOR_A -le $MAJOR_B ] && [ $MINOR_A -lt $MINOR_B ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ $MAJOR_A -le $MAJOR_B ] && [ $MINOR_A -le $MINOR_B ] && [ $PATCH_A -lt $PATCH_B ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ "_$SPECIAL_A" == "_" ] && [ "_$SPECIAL_B" == "_" ] ; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ "_$SPECIAL_A" == "_" ] && [ "_$SPECIAL_B" != "_" ] ; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ "_$SPECIAL_A" != "_" ] && [ "_$SPECIAL_B" == "_" ] ; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ "_$SPECIAL_A" < "_$SPECIAL_B" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Returns the tag of the latest stable release (in terms of semver and not of release date)
|
|
||||||
get_latest() {
|
|
||||||
temp_file='temp_file' # temp_file needed because the grep would start before the download is over
|
|
||||||
curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file"
|
|
||||||
releases=$(cat "$temp_file" | \
|
|
||||||
grep -E "tag_name|draft|prerelease" \
|
|
||||||
| tr -d ',"' | cut -d ':' -f2 | tr -d ' ')
|
|
||||||
# Returns a list of [tag_name draft_boolean prerelease_boolean ...]
|
|
||||||
# Ex: v0.10.1 false false v0.9.1-rc.1 false true v0.9.0 false false...
|
|
||||||
|
|
||||||
i=0
|
|
||||||
latest=""
|
|
||||||
current_tag=""
|
|
||||||
for release_info in $releases; do
|
|
||||||
if [ $i -eq 0 ]; then # Checking tag_name
|
|
||||||
if echo "$release_info" | grep -q "$GREP_SEMVER_REGEXP"; then # If it's not an alpha or beta release
|
|
||||||
current_tag=$release_info
|
|
||||||
else
|
|
||||||
current_tag=""
|
|
||||||
fi
|
|
||||||
i=1
|
|
||||||
elif [ $i -eq 1 ]; then # Checking draft boolean
|
|
||||||
if [ "$release_info" = "true" ]; then
|
|
||||||
current_tag=""
|
|
||||||
fi
|
|
||||||
i=2
|
|
||||||
elif [ $i -eq 2 ]; then # Checking prerelease boolean
|
|
||||||
if [ "$release_info" = "true" ]; then
|
|
||||||
current_tag=""
|
|
||||||
fi
|
|
||||||
i=0
|
|
||||||
if [ "$current_tag" != "" ]; then # If the current_tag is valid
|
|
||||||
if [ "$latest" = "" ]; then # If there is no latest yet
|
|
||||||
latest="$current_tag"
|
|
||||||
else
|
|
||||||
semverLT $current_tag $latest # Comparing latest and the current tag
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
latest="$current_tag"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f "$temp_file"
|
|
||||||
echo $latest
|
|
||||||
}
|
|
||||||
|
|
||||||
# MAIN
|
|
||||||
current_tag="$(echo $GITHUB_REF | tr -d 'refs/tags/')"
|
|
||||||
latest="$(get_latest)"
|
|
||||||
|
|
||||||
if [ "$current_tag" != "$latest" ]; then
|
|
||||||
# The current release tag is not the latest
|
|
||||||
echo "false"
|
|
||||||
else
|
|
||||||
# The current release tag is the latest
|
|
||||||
echo "true"
|
|
||||||
fi
|
|
11
.github/workflows/latest-git-tag.yml
vendored
11
.github/workflows/latest-git-tag.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
# Create or update a latest git tag when releasing a stable vesrsin of Meilisearch
|
# Create or update a latest git tag when releasing a stable version of Meilisearch
|
||||||
name: Update latest git tag
|
name: Update latest git tag
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@ -6,6 +6,15 @@ on:
|
|||||||
types: [released]
|
types: [released]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-version:
|
||||||
|
name: Check the version validity
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Check release validity
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
run: bash .github/scripts/check-release.sh
|
||||||
|
|
||||||
update-latest-tag:
|
update-latest-tag:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
Loading…
Reference in New Issue
Block a user