Skip to content

Commit e3d53a1

Browse files
committed
Merge branch 'DEV-FG-ci-improvement' into 'master'
Improvements on CI See merge request cstao/jube!42
2 parents 78e0e99 + 0caee50 commit e3d53a1

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.gitlab-ci.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,46 @@ dependencies:
5252
after_script:
5353
- cd "${CI_PROJECT_DIR}/${CI_JOB_NAME#*:}"
5454
- git status
55-
# Add list of files
56-
- git add ${FILE_LIST}
57-
- git commit -m "${COMMIT_MESSAGE} (Runner ID:${CI_RUNNER_ID})"
58-
- git push -o ci.skip https://gitlab-ci-token:${GIT_PUSH_TOKEN}@${CI_REPOSITORY_URL#*@}
55+
# Add list of files and commit, if there are changes
56+
- |
57+
if [[ -z $(git status --untracked-files=no --porcelain) ]]
58+
then
59+
echo "Nothing to commit"
60+
else
61+
git diff
62+
git add ${FILE_LIST}
63+
git commit -m "${COMMIT_MESSAGE} (Runner ID:${CI_RUNNER_ID})"
64+
git push -o ci.skip https://gitlab-ci-token:${GIT_PUSH_TOKEN}@${CI_REPOSITORY_URL#*@}
65+
fi
5966
# Cleaning up
6067
- cd ${CI_PROJECT_DIR}
6168
- rm -r "${CI_PROJECT_DIR}/${CI_JOB_NAME#*:}"
6269

6370
build:year:
6471
variables:
6572
FILE_LIST: -u
66-
COMMIT_MESSAGE: "Updating Year"
73+
COMMIT_MESSAGE: "Checking if year must be updated"
6774
stage: build
6875
script:
6976
# Updating all Copyright years
70-
- find ${CI_PROJECT_DIR} -type f -exec sed -i "s/Copyright (C) 2008-$((`date +%Y`-1))/Copyright (C) 2008-`date +%Y`/g" {} \;
77+
- find ${CI_PROJECT_DIR} -type f -exec sed -i "s/Copyright (C) 2008-[0-9]\{4\}/Copyright (C) 2008-`date +%Y`/g" {} \;
7178
# Updating years on documentation
72-
- sed -i "s/$((`date +%Y`-1))/`date +%Y`/g" ${CI_PROJECT_DIR}/docs/conf.py
79+
- sed -i "s/[0-9]\{4\}, JUBE Developer Team/`date +%Y`, JUBE Developer Team/g" ${CI_PROJECT_DIR}/docs/conf.py
7380
<<: *push_files
7481
rules:
75-
- if: $CI_COMMIT_TAG =~ /^REL-.*/
82+
- if: '$CI_COMMIT_BRANCH == "master"' # Only on the master branch
7683
resource_group: gitpush
7784

7885
build:version:
7986
variables:
8087
FILE_LIST: jube2/conf.py docs/conf.py setup.py
81-
COMMIT_MESSAGE: "Updating Version"
88+
COMMIT_MESSAGE: "Checking if version must be updated"
8289
stage: build
8390
script:
84-
- export RELEASE=${CI_COMMIT_TAG#*-}
91+
- export RELEASE=`grep -o -m1 "Version \d\.\d\.\d\(-[^ ]\+\)\?" docs/release_notes.rst | cut -d " " -f2`
8592
- export VERSION=${RELEASE%.*}
93+
- |
94+
echo "Last version on docs/release_notes.rst: $RELEASE"
8695
# Updating version in files
8796
- |
8897
sed -i "s/'version': '.*'/'version': '$RELEASE'/g" ${CI_PROJECT_DIR}/setup.py
@@ -91,7 +100,9 @@ build:version:
91100
- sed -i "s/release = '.*'/release = '$RELEASE'/g" ${CI_PROJECT_DIR}/docs/conf.py
92101
<<: *push_files
93102
rules:
94-
- if: $CI_COMMIT_TAG =~ /^REL-.*/
103+
- if: '$CI_COMMIT_BRANCH == "master"' # Only on the master branch
104+
changes:
105+
- docs/release_notes.rst
95106
resource_group: gitpush
96107

97108
build:release_notes:
@@ -193,9 +204,6 @@ tests:conf_tests:
193204

194205
deploy:dist_package:
195206
stage: deploy
196-
needs:
197-
- build:year
198-
- build:version
199207
<<: *clone_repo
200208
script:
201209
- cd "${CI_PROJECT_DIR}/${CI_JOB_NAME#*:}"

0 commit comments

Comments
 (0)