From 3bb3a92b76cce122c3216d2d2dd21461d256d91a Mon Sep 17 00:00:00 2001 From: Mathias Chouet <mathias.chouet@irstea.fr> Date: Fri, 17 Apr 2020 10:56:56 +0200 Subject: [PATCH] Update README and scripts for deployment of new stable version --- .gitlab-ci.yml | 1 + README.md | 35 +++++++--- scripts/deploy-new-stable-version.sh | 97 ++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 8 deletions(-) create mode 100755 scripts/deploy-new-stable-version.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 934f27b81..927ed83be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,6 +30,7 @@ jalhyd: - web script: - JALHYD_BRANCH=`cat jalhyd_branch` + - echo "CI_COMMIT_REF_NAME - $CI_COMMIT_REF_NAME" - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then JALHYD_BRANCH="master"; fi - if [ "$CI_COMMIT_REF_NAME" = "devel" ]; then JALHYD_BRANCH="devel"; fi - echo "Branche JalHyd - $JALHYD_BRANCH" diff --git a/README.md b/README.md index dfa6eb7ee..a7dfb7365 100644 --- a/README.md +++ b/README.md @@ -251,20 +251,39 @@ sudo find /usr/lib/node_modules/protractor -regextype sed -regex "^.*/chromedriv Use [semantic versioning](https://semver.org/). -Before releasing a new stable version, one should complete the following files +**It's discouraged to execute release steps manually, see Release Script below** + +Before releasing a new stable version, a new version of JaLHyd should be tagged, see + +Then, one should complete the following files - `CHANGELOG.md` - - `package.json` (update "version") + - `package.json` (update "version", or use `npm version`) - `jalhyd_branch` (be sure that it contains "master" or is empty) Every stable version should be tagged with both - the `stable` tag - a version tag of the form `X.Y.Z` (semver) -The `stable` tag should be set **before** the version tag, so that `git describe` returns `X.Y.Z` (latest tag). +The `stable` tag should be set **before** the version tag, so that `git describe` returns `X.Y.Z` (latest tag). There should be **at least 1s** between the two tag commands, so that date sorting is not confused. + +### Release script + +**Important:** the release script assumes that you run it from the current nghyd source directory `nghyd`, and that JaLHyd source directory `jalhyd` is present at the same level. + +This script: + * checks out "master" branch of JaLHyd, pulls the latest changes, installs dependencies, runs unit tests, commits changes if any + * updates JaLHyd version, commits changes + * creates the right tags for JaLHyd and pushes them + * checks out "master" branch of NgHyd, pulls the latest changes, installs dependencies, commits changes if any + * updates NgHyd version, commits changes + * creates the right tags for NgHyd and pushes them + +It **does not** check that `jalhyd_branch` is OK nor that `jalhyd/CHANGELOG.md` and `nghyd/CHANGELOG.md` are up to date, but reminds you to do it. + +Once tags are pushed, Gitlab CI/CD takes care of building and deploying the new packages. + +Example for a **4.10.4** version : -Here are the steps to follow for an example **4.5.0** version ```sh -git tag -fa stable -git tag -fa 4.5.0 -git push --tags --force -``` \ No newline at end of file +./scripts/deploy-new-stable-version.sh 4.10.4 +``` diff --git a/scripts/deploy-new-stable-version.sh b/scripts/deploy-new-stable-version.sh new file mode 100755 index 000000000..3c65c3ae5 --- /dev/null +++ b/scripts/deploy-new-stable-version.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# Use this script to tag new stable versions of JaLHyd and NgHyd, to be then built and deployed by Gitlab CI/CD +# +# This script requires: +# * bash +# * git +# * npm + +# exit on error +set -e + +VERSION=$1 + +if [[ $VERSION == "" ]] +then + echo "Utilisation: $0 x.y.z + ex: $0 4.7.0" + exit 1 +fi + +# 0. changelog +read -p "Avez-vous rempli jalhyd_branch, et les CHANGELOG de JaLHyd et NgHyd pour la version $VERSION ? (o/N) " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Oo]$ ]] +then + echo "Remplissez d'abord nghyd/jalhyd_branch, jalhyd/CHANGELOG.md et nghyd/CHANGELOG.md, puis faites 'commit' et 'push' dans chaque dépôt" + exit 2 +fi + +# 1. JaLHyd ################################################################### + +echo "BUILDING JALHYD" +cd ../jalhyd + +# 1.2 update Git repository and test +git checkout master +git pull --rebase +npm install +npm run jasmine +if [ ! -z "$(git status --porcelain)" ] +then + echo "commiting changes induced by 'npm install'" + git commit -a -m "verify dependencies (npm install) before deploying version $VERSION" +fi + +# 1.3 version in package.* +npm version "$VERSION" --allow-same-version --git-tag-version=false +if [ ! -z "$(git status --porcelain)" ] +then + echo "commiting changes induced by 'npm version'" + git commit -a -m "update package.* to version $VERSION" +fi + +# 1.4 tags +git tag -fa "nghyd_$VERSION" -m "release version $VERSION" +sleep 1 +git tag -fa stable -m "stable version" + +# 1.5 push code, push tags +git push +git push --tags --force + + +# 2. NgHyd #################################################################### + +echo "BUILDING NGHYD" +cd ../nghyd + +# 2.2 update Git repository +git checkout master +git pull --rebase +npm install +if [ ! -z "$(git status --porcelain)" ] +then + echo "commiting changes induced by 'npm install'" + git commit -a -m "verify dependencies (npm install) before deploying version $VERSION" +fi + +# 2.3 version in package.* +npm version "$VERSION" --allow-same-version --git-tag-version=false +if [ ! -z "$(git status --porcelain)" ] +then + echo "commiting changes induced by 'npm version'" + git commit -a -m "update package.* to version $VERSION" +fi + +# 2.4 tags +git tag -fa stable -m "stable version" +sleep 1 +git tag -fa "$VERSION" -m "release version $VERSION" + +# 2.5 push code, push tags +git push +git push --tags --force + +echo "Tagging done, Gitlab CI/CD should take care of the rest." -- GitLab