Commit 9545ba9b authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

CI: update manifest logic

parent c33c711f
......@@ -7,11 +7,11 @@
# First we copy the installer into the deployment directory, denoted by the
# $FSLINSTALLER_DEPLOY_DIRECTORY environment variable.
# copy the installer to the deploy
# directory, stamping it along the way.
# copy the installer to the deploy directory,
# stamping it with the new version number.
PATTERN="s/^__version__ =.*/__version__ = '$CI_COMMIT_TAG'/g"
DEST=$FSLINSTALLER_DEPLOY_DIRECTORY/fslinstaller.py
cat fslinstaller.py | sed -e "$PATTERN" > $DEST
cat fslinstaller.py | sed "$PATTERN" > $DEST
# Then we call the update_manifest.py script, which opens a merge request
# on the fsl/conda/manifest repository, to update the latest available
......
......@@ -2,12 +2,13 @@
#
# This script is called when a new version of the fslinstaller.py script is
# tagged. It opens a merge request on the GitLab fsl/conda/manifest project,
# to update the FSL release manifest file so that it contains the new installer.
# to update the FSL release manifest file so that it contains the new installer
# version string.
#
import os
import re
from fsl_ci import (USERNAME,
EMAIL,
......@@ -20,32 +21,56 @@ from fsl_ci.gitlab import (open_merge_request,
MANIFEST_PATH = 'fsl/conda/manifest'
COMMIT_MSG = 'MNT: Update fslinstaller version to latest [{tag}] ' \
COMMIT_MSG = 'MNT: Update fslinstaller version to latest [{}] ' \
'in FSL installer manifest'
MERGE_REQUEST_MSG = """
This MR was automatically opened as a result of a new tag being added to
the fsl/installer> project. It updates the installer version in the FSL
release `manifest.json` file to the latest installer version.
This MR was automatically opened as a result of a new tag being added
to the fsl/installer> project. It updates the installer version in
fsl-release.yml to the latest installer version.
""".strip()
def update_manifest(version):
with open('fsl-release.yml', 'rt') as f:
lines = list(f.readlines())
pat = r'installer:.*'
updated = False
for i, line in enumerate(lines):
if re.match(pat, line):
lines[i] = f'installer: {version}\n'
updated = True
break
if not updated:
for line in lines:
print(line.rstrip())
raise RuntimeError('Could not find installer section '
'in fsl-release.yml')
with open('fsl-release.yml', 'wt') as f:
for line in lines:
f.write(line)
def checkout_and_update_manifest(server, token, tag):
manifest_url = f'{server}/{MANIFEST_PATH}'
branch = f'mnt/installer{tag}'
branch = f'mnt/installer-{tag}'
branch = gen_branch_name(branch, MANIFEST_PATH, server, token)
msg = COMMIT_MSG.format(tag)
sprun(f'git clone {manifest_url} manifest')
with indir('manifest'):
sprun(f'git config user.name {USERNAME}')
sprun(f'git config user.email {EMAIL}')
sprun(f'git checkout -b {branch} master')
update_manifest()
update_manifest(tag)
sprun( 'git add *')
sprun(f'git commit -m "{COMMIT_MSG}"')
sprun(f'git commit -m "{msg}"')
sprun(f'git push origin {branch}')
return branch
......
......@@ -9,7 +9,6 @@
# directory $FSLINSTALLER_DEPLOY_DIRECTORY
# into which the fslinstaller.py script can
# be copied.
stages:
- test
- release
......@@ -81,5 +80,6 @@ release:
- fslconda-channel-host
rules:
- if: '$CI_COMMIT_TAG != null'
when: manual
script:
- bash ./.ci/new_release.sh
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment