diff --git a/.gitlab/release.yml b/.gitlab/release.yml index eade839d37879f0245921eba17df7055770e611d..e10efe6f23ba78743391271bc695efc7d66fc45b 100644 --- a/.gitlab/release.yml +++ b/.gitlab/release.yml @@ -2,7 +2,7 @@ release: stage: deploy rules: - - if: $CI_COMMIT_BRANCH =~ /^release-.*$/ && $CI_PIPELINE_SOURCE != "schedule" + - if: $CI_COMMIT_TAG =~ /^v[0-9]\.[0-9]\.[0-9]$/ && $CI_PIPELINE_SOURCE != "schedule" dependencies: [] artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" diff --git a/tools/release.sh b/tools/release.sh index c184aad1a5f29b78b95b1a8d7ee790e089ce78d9..4f4d76cfa5dbb93c68e2e160bf256904ae910a9f 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -5,7 +5,7 @@ # @copyright 2013-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, # Univ. Bordeaux. All rights reserved. # -# @brief Script to generate the release when pushing a branch and tag of the same name +# @brief Script to generate the release when pushing a tag # # @version 1.2.0 # @author Florent Pruvost @@ -18,9 +18,7 @@ # Steps to do the release: # - Update information in the code (see update_release.sh) # - Update the ChangeLog -# - Push the hash on solverstack as: -# - a tag named vx.x.x -# - a branch named release-x.x.x (will trigger the CI to generate the release) +# - Create a tag named vx.x.x and push it on solverstack (will trigger the CI to generate the release) # changelog="" function gen_changelog() @@ -40,7 +38,7 @@ function gen_changelog() #echo $line done - changelog="$changelog\nWARNING: Download the source archive by clicking on the link __Download release__ above, please do not consider the automatic Source code links as they are missing the submodules.\n" + changelog="$changelog\nWARNING: Download the source archive by clicking on the link __Download release__ above, please do not consider the automatic Source code links as they are missing the submodules.\nVisit the [documentation](https://solverstack.gitlabpages.inria.fr/chameleon/#quickstart-install) to see how to install Chameleon." } release="" @@ -50,9 +48,11 @@ function get_release() release=$( head -n $firstline ChangeLog | tail -n 1 | sed 's/chameleon\-//' ) } +set -x + # Get the release name through the branch name, and through the ChangeLog file. # Both have to match to be correct -RELEASE_NAME=`echo $CI_COMMIT_REF_NAME | cut -d - -f 2` +RELEASE_NAME=`echo $CI_COMMIT_TAG | cut -d v -f 2` get_release if [ -z "$RELEASE_NAME" -o -z "$release" -o "$RELEASE_NAME" != "$release" ] @@ -65,23 +65,22 @@ fi wget https://raw.githubusercontent.com/Kentzo/git-archive-all/master/git_archive_all.py python3 git_archive_all.py --force-submodules chameleon-$RELEASE_NAME.tar.gz -# upload the source archive -GETURL=`echo curl --request POST --header \"PRIVATE-TOKEN: $RELEASE_TOKEN\" --form \"file=\@chameleon-$RELEASE_NAME.tar.gz\" https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/uploads` -MYURL=`eval $GETURL | jq .url | sed "s#\"##g"` +# upload the source archive to the Gitlab's Package registry +curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./chameleon-$RELEASE_NAME.tar.gz "https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/packages/generic/source/$CI_COMMIT_TAG/chameleon-$RELEASE_NAME.tar.gz" # extract the change log from ChangeLog gen_changelog echo $changelog # Try to remove the release if it already exists -curl --request DELETE --header "PRIVATE-TOKEN: $RELEASE_TOKEN" https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/releases/v$RELEASE_NAME +curl --request DELETE --header "JOB-TOKEN: $CI_JOB_TOKEN" https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/releases/v$RELEASE_NAME -# create the release and the associated tag -COMMAND=`echo curl --header \"Content-Type: application/json\" --header \"PRIVATE-TOKEN: $RELEASE_TOKEN\" \ +# create the release associated to the tag +COMMAND=`echo curl --header \"Content-Type: application/json\" --header \"JOB-TOKEN: $CI_JOB_TOKEN\" \ --data \'{ \"name\": \"v$RELEASE_NAME\", \ \"tag_name\": \"v$RELEASE_NAME\", \ \"ref\": \"$CI_COMMIT_REF_NAME\", \ \"description\": \"$changelog\", \ - \"assets\": { \"links\": [{ \"name\": \"Download release\", \"url\": \"$CI_PROJECT_URL$MYURL\" }] } }\' \ + \"assets\": { \"links\": [{ \"name\": \"Download release chameleon-$RELEASE_NAME.tar.gz\", \"url\": \"https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/packages/generic/source/$CI_COMMIT_TAG/chameleon-$RELEASE_NAME.tar.gz\" }] } }\' \ --request POST https://gitlab.inria.fr/api/v4/projects/$CI_PROJECT_ID/releases` eval $COMMAND