From 2dde6fadb4f20610c07e47ecae0f9c397b7e83c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Thu, 16 Jun 2022 19:27:27 +0200 Subject: [PATCH 1/7] Check the version in Cargo.toml before publishing --- .github/scripts/check-release.sh | 28 ++++++++++++ .github/workflows/publish-binaries.yml | 10 +++++ .github/workflows/publish-deb-brew-pkg.yml | 10 +++++ .github/workflows/publish-docker-images.yml | 47 ++++++++++++--------- 4 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 .github/scripts/check-release.sh diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh new file mode 100644 index 000000000..230c3234f --- /dev/null +++ b/.github/scripts/check-release.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Checking if current tag matches the package version +current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') +file1='meilisearch-auth/Cargo.toml' +file2='meilisearch-http/Cargo.toml' +file3='meilisearch-lib/Cargo.toml' +file4='meilisearch-types/Cargo.toml' +file5='Cargo.lock' + +file_tag1=$(grep '^version = ' $file1 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') +file_tag2=$(grep '^version = ' $file2 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') +file_tag3=$(grep '^version = ' $file3 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') +file_tag4=$(grep '^version = ' $file4 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') +file_tag5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') + +if [ "$current_tag" != "$file_tag1" ] || [ "$current_tag" != "$file_tag2" ] || [ "$current_tag" != "$file_tag3" ] || [ "$current_tag" != "$file_tag4" ] || [ "$current_tag" != "$file_tag5" ]; then + echo "Error: the current tag does not match the version in package file(s)." + echo "$file1: found $file_tag1 - expected $current_tag" + echo "$file2: found $file_tag2 - expected $current_tag" + echo "$file3: found $file_tag3 - expected $current_tag" + echo "$file4: found $file_tag4 - expected $current_tag" + echo "$file5: found $file_tag5 - expected $current_tag" + exit 1 +fi + +echo 'OK' +exit 0 diff --git a/.github/workflows/publish-binaries.yml b/.github/workflows/publish-binaries.yml index 304798d75..eee7449a8 100644 --- a/.github/workflows/publish-binaries.yml +++ b/.github/workflows/publish-binaries.yml @@ -5,9 +5,18 @@ on: name: Publish binaries to release jobs: + check-version: + name: Check the version validity + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check release validity + run: sh .github/scripts/check-release.sh + publish: name: Publish binary for ${{ matrix.os }} runs-on: ${{ matrix.os }} + needs: check-version strategy: fail-fast: false matrix: @@ -41,6 +50,7 @@ jobs: publish-aarch64: name: Publish binary for aarch64 runs-on: ${{ matrix.os }} + needs: check-version continue-on-error: false strategy: fail-fast: false diff --git a/.github/workflows/publish-deb-brew-pkg.yml b/.github/workflows/publish-deb-brew-pkg.yml index 6a5a21287..7618496e9 100644 --- a/.github/workflows/publish-deb-brew-pkg.yml +++ b/.github/workflows/publish-deb-brew-pkg.yml @@ -5,9 +5,18 @@ on: types: [released] jobs: + check-version: + name: Check the version validity + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check release validity + run: sh .github/scripts/check-release.sh + debian: name: Publish debian packagge runs-on: ubuntu-18.04 + needs: check-version steps: - uses: hecrj/setup-rust-action@master with: @@ -30,6 +39,7 @@ jobs: homebrew: name: Bump Homebrew formula runs-on: ubuntu-18.04 + needs: check-version steps: - name: Create PR to Homebrew uses: mislav/bump-homebrew-formula-action@v1 diff --git a/.github/workflows/publish-docker-images.yml b/.github/workflows/publish-docker-images.yml index 8d24c1123..223ef41b3 100644 --- a/.github/workflows/publish-docker-images.yml +++ b/.github/workflows/publish-docker-images.yml @@ -5,8 +5,6 @@ on: push: tags: - '*' - release: - types: [released] name: Publish tagged images to Docker Hub @@ -14,45 +12,54 @@ jobs: docker: runs-on: docker steps: + - uses: actions/checkout@v2 + + # Check if the tag has the v.. format. If yes, it means we are publishing an official release. + # In this situation, we need to set `output.stable` to create/update the following tags (additionally to the `vX.Y.Z` Docker tag): + # - a `vX.Y` (without patch version) Docker tag + # - a `latest` Docker tag + - name: Check tag format + if: github.event_name != 'schedule' + id: check-tag-format + run: | + escaped_tag=$(printf "%q" ${{ github.ref_name }}) + + if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo ::set-output name=stable::true + else + echo ::set-output name=stable::false + fi + + # Check only the validity of the tag for official releases (not for pre-releases or other tags) + - name: Check release validity + if: github.event_name != 'schedule' && steps.check-tag-format.outputs.stable + run: sh .github/scripts/check-release.sh + - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub + - name: Login to Docker Hub if: github.event_name != 'schedule' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Check tag format - id: check-tag-format - run: | - # Escape submitted tag name - escaped_tag=$(printf "%q" ${{ github.ref_name }}) - - # Check if tag has format v.. and set output.match - # to create a vX.Y (without patch version) Docker tag - if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo ::set-output name=match::true - else - echo ::set-output name=match::false - fi - - name: Docker meta id: meta uses: docker/metadata-action@v3 with: images: getmeili/meilisearch - # The lastest tag is only pushed for the official Meilisearch release + # The lastest and `vX.Y` tags are only pushed for the official Meilisearch releases # See https://github.com/docker/metadata-action#latest-tag flavor: latest=false tags: | type=ref,event=tag - type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.match }} - type=raw,value=latest,enable=${{ github.event_name == 'release' }} + type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.stable }} + type=raw,value=latest,enable=${{ steps.check-tag-format.outputs.stable }} - name: Build and push id: docker_build From 5318e53248eccd0efdc36bfcd2d0c3a4b061a541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Tue, 21 Jun 2022 10:08:07 +0200 Subject: [PATCH 2/7] Move is-latest-release.sh script into the scripts folder --- .github/{ => scripts}/is-latest-release.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename .github/{ => scripts}/is-latest-release.sh (90%) diff --git a/.github/is-latest-release.sh b/.github/scripts/is-latest-release.sh similarity index 90% rename from .github/is-latest-release.sh rename to .github/scripts/is-latest-release.sh index 0c1db61c2..af0ff45b3 100644 --- a/.github/is-latest-release.sh +++ b/.github/scripts/is-latest-release.sh @@ -1,14 +1,14 @@ #!/bin/sh -# Checks if the current tag should be the latest (in terms of semver and not of release date). -# Ex: previous tag -> v0.10.1 -# new tag -> v0.8.12 -# The new tag should not be the latest -# So it returns "false", the CI should not run for the release v0.8.2 - -# Used in GHA in publish-docker-latest.yml +# 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] From c484d2864617234807541433e75567f9ac9d0949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar=20-=20curqui?= Date: Tue, 21 Jun 2022 10:14:17 +0200 Subject: [PATCH 3/7] Update .github/scripts/check-release.sh Co-authored-by: Tamo --- .github/scripts/check-release.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh index 230c3234f..ea138c4d7 100644 --- a/.github/scripts/check-release.sh +++ b/.github/scripts/check-release.sh @@ -8,21 +8,18 @@ file3='meilisearch-lib/Cargo.toml' file4='meilisearch-types/Cargo.toml' file5='Cargo.lock' -file_tag1=$(grep '^version = ' $file1 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') -file_tag2=$(grep '^version = ' $file2 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') -file_tag3=$(grep '^version = ' $file3 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') -file_tag4=$(grep '^version = ' $file4 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') -file_tag5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') -if [ "$current_tag" != "$file_tag1" ] || [ "$current_tag" != "$file_tag2" ] || [ "$current_tag" != "$file_tag3" ] || [ "$current_tag" != "$file_tag4" ] || [ "$current_tag" != "$file_tag5" ]; then - echo "Error: the current tag does not match the version in package file(s)." - echo "$file1: found $file_tag1 - expected $current_tag" - echo "$file2: found $file_tag2 - expected $current_tag" - echo "$file3: found $file_tag3 - expected $current_tag" - echo "$file4: found $file_tag4 - expected $current_tag" - echo "$file5: found $file_tag5 - expected $current_tag" - exit 1 -fi +file5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version) + +for file in $file1 $file2 $file3 $file4 $file5; +do + file_tag=$(grep '^version = ' $file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') + if [ "$current_tag" != "$file_tag" ]; then + echo "Error: the current tag does not match the version in package file(s)." + echo "$file: found $file_tag - expected $current_tag" + exit 1 + fi +done echo 'OK' exit 0 From de16de20f46390efe9619bf3788dd802a7a091f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar=20-=20curqui?= Date: Tue, 21 Jun 2022 10:14:24 +0200 Subject: [PATCH 4/7] Update .github/scripts/check-release.sh Co-authored-by: Tamo --- .github/scripts/check-release.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh index ea138c4d7..189019ce1 100644 --- a/.github/scripts/check-release.sh +++ b/.github/scripts/check-release.sh @@ -2,11 +2,8 @@ # Checking if current tag matches the package version current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') -file1='meilisearch-auth/Cargo.toml' -file2='meilisearch-http/Cargo.toml' -file3='meilisearch-lib/Cargo.toml' -file4='meilisearch-types/Cargo.toml' -file5='Cargo.lock' +files='*/Cargo.toml' +lock_file='Cargo.lock' file5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version) From c6ed756dbc3573c385bb6ed14e9da49f20e37c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Tue, 21 Jun 2022 10:46:32 +0200 Subject: [PATCH 5/7] Update script after review --- .github/scripts/check-release.sh | 34 ++++++++++++++++------------ .github/scripts/is-latest-release.sh | 2 +- Cargo.lock | 2 +- permissive-json-pointer/Cargo.toml | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh index 189019ce1..bad957cff 100644 --- a/.github/scripts/check-release.sh +++ b/.github/scripts/check-release.sh @@ -1,22 +1,26 @@ #!/bin/sh -# Checking if current tag matches the package version -current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') -files='*/Cargo.toml' -lock_file='Cargo.lock' - - -file5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version) - -for file in $file1 $file2 $file3 $file4 $file5; -do - file_tag=$(grep '^version = ' $file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') - if [ "$current_tag" != "$file_tag" ]; then - echo "Error: the current tag does not match the version in package file(s)." - echo "$file: found $file_tag - expected $current_tag" +# check_tag $current_tag $file_tag $file_name +function check_tag { + if [ "$1" != "$2" ]; then + echo "Error: the current tag does not match the version in $3:" + echo "Found $1 - expected $2" exit 1 - fi + fi +} + +current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') + +files='*/Cargo.toml' +for file in $files; +do + file_tag="$(grep '^version = ' $file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')" + check_tag $current_tag $file_tag $file done +lock_file='Cargo.lock' +lock_tag=$(grep -A 1 'name = "meilisearch-auth"' $lock_file | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') +check_tag $current_tag $lock_tag $lock_file + echo 'OK' exit 0 diff --git a/.github/scripts/is-latest-release.sh b/.github/scripts/is-latest-release.sh index af0ff45b3..81534a2f7 100644 --- a/.github/scripts/is-latest-release.sh +++ b/.github/scripts/is-latest-release.sh @@ -7,7 +7,7 @@ # 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 +# 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] diff --git a/Cargo.lock b/Cargo.lock index 1bd47e355..ff2325361 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2515,7 +2515,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "permissive-json-pointer" -version = "0.2.0" +version = "0.28.0" dependencies = [ "big_s", "serde_json", diff --git a/permissive-json-pointer/Cargo.toml b/permissive-json-pointer/Cargo.toml index b50f30f19..9e01b81ab 100644 --- a/permissive-json-pointer/Cargo.toml +++ b/permissive-json-pointer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "permissive-json-pointer" -version = "0.2.0" +version = "0.28.0" edition = "2021" description = "A permissive json pointer" readme = "README.md" From 7490383d4f71d282a075cf3e9421d596c59b51c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Tue, 21 Jun 2022 19:17:33 +0200 Subject: [PATCH 6/7] Update the not-released version in Cargo.toml files --- Cargo.lock | 6 +++--- meilisearch-lib/Cargo.toml | 2 +- meilisearch-types/Cargo.toml | 2 +- permissive-json-pointer/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff2325361..f736ebecb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2092,7 +2092,7 @@ dependencies = [ [[package]] name = "meilisearch-lib" -version = "0.28.0" +version = "0.0.0" dependencies = [ "actix-rt", "actix-web", @@ -2154,7 +2154,7 @@ dependencies = [ [[package]] name = "meilisearch-types" -version = "0.28.0" +version = "0.0.0" dependencies = [ "actix-web", "proptest", @@ -2515,7 +2515,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "permissive-json-pointer" -version = "0.28.0" +version = "0.0.0" dependencies = [ "big_s", "serde_json", diff --git a/meilisearch-lib/Cargo.toml b/meilisearch-lib/Cargo.toml index 094c79901..d9603e1d5 100644 --- a/meilisearch-lib/Cargo.toml +++ b/meilisearch-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meilisearch-lib" -version = "0.28.0" +version = "0.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/meilisearch-types/Cargo.toml b/meilisearch-types/Cargo.toml index 6949722e7..1614f5b34 100644 --- a/meilisearch-types/Cargo.toml +++ b/meilisearch-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meilisearch-types" -version = "0.28.0" +version = "0.0.0" authors = ["marin "] edition = "2021" diff --git a/permissive-json-pointer/Cargo.toml b/permissive-json-pointer/Cargo.toml index 9e01b81ab..9e01f8807 100644 --- a/permissive-json-pointer/Cargo.toml +++ b/permissive-json-pointer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "permissive-json-pointer" -version = "0.28.0" +version = "0.0.0" edition = "2021" description = "A permissive json pointer" readme = "README.md" From 32c8846514dba7ea03b169c3002bf8365dd714ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Wed, 22 Jun 2022 12:20:12 +0200 Subject: [PATCH 7/7] Rollback 0.0.0 versionning --- .github/scripts/check-release.sh | 20 +++++++++++--------- Cargo.lock | 6 +++--- meilisearch-lib/Cargo.toml | 2 +- meilisearch-types/Cargo.toml | 2 +- permissive-json-pointer/Cargo.toml | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh index bad957cff..3c8dd64a7 100644 --- a/.github/scripts/check-release.sh +++ b/.github/scripts/check-release.sh @@ -3,24 +3,26 @@ # check_tag $current_tag $file_tag $file_name function check_tag { if [ "$1" != "$2" ]; then - echo "Error: the current tag does not match the version in $3:" - echo "Found $1 - expected $2" - exit 1 + echo "Error: the current tag does not match the version in $3: found $1 - expected $2" + ret=1 fi } +ret=0 current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') -files='*/Cargo.toml' -for file in $files; +toml_files='*/Cargo.toml' +for toml_file in $toml_files; do - file_tag="$(grep '^version = ' $file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')" - check_tag $current_tag $file_tag $file + file_tag="$(grep '^version = ' $toml_file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')" + check_tag $current_tag $file_tag $toml_file done lock_file='Cargo.lock' lock_tag=$(grep -A 1 'name = "meilisearch-auth"' $lock_file | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') check_tag $current_tag $lock_tag $lock_file -echo 'OK' -exit 0 +if [ "$ret" -eq 0 ] ; then + echo 'OK' +fi +exit $ret diff --git a/Cargo.lock b/Cargo.lock index f736ebecb..ff2325361 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2092,7 +2092,7 @@ dependencies = [ [[package]] name = "meilisearch-lib" -version = "0.0.0" +version = "0.28.0" dependencies = [ "actix-rt", "actix-web", @@ -2154,7 +2154,7 @@ dependencies = [ [[package]] name = "meilisearch-types" -version = "0.0.0" +version = "0.28.0" dependencies = [ "actix-web", "proptest", @@ -2515,7 +2515,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "permissive-json-pointer" -version = "0.0.0" +version = "0.28.0" dependencies = [ "big_s", "serde_json", diff --git a/meilisearch-lib/Cargo.toml b/meilisearch-lib/Cargo.toml index d9603e1d5..094c79901 100644 --- a/meilisearch-lib/Cargo.toml +++ b/meilisearch-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meilisearch-lib" -version = "0.0.0" +version = "0.28.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/meilisearch-types/Cargo.toml b/meilisearch-types/Cargo.toml index 1614f5b34..6949722e7 100644 --- a/meilisearch-types/Cargo.toml +++ b/meilisearch-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meilisearch-types" -version = "0.0.0" +version = "0.28.0" authors = ["marin "] edition = "2021" diff --git a/permissive-json-pointer/Cargo.toml b/permissive-json-pointer/Cargo.toml index 9e01f8807..9e01b81ab 100644 --- a/permissive-json-pointer/Cargo.toml +++ b/permissive-json-pointer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "permissive-json-pointer" -version = "0.0.0" +version = "0.28.0" edition = "2021" description = "A permissive json pointer" readme = "README.md"