Commit 5442239f authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'enh/clear-release-dir' into 'master'

Enh/clear release dir

See merge request fsl/conda/manifest-rules!32
parents dd01090c b86c3ff0
......@@ -20,11 +20,13 @@ test:
script:
- pip install git+https://git.fmrib.ox.ac.uk/fsl/conda/fsl-ci-rules.git
- pip install .
- which clear_release_files
- which deploy_files
- which generate_environment_files
- which generate_manifest_file
- which test_environment
- which test_manifest
- python -c 'import manifest_rules.clear_release_files'
- python -c 'import manifest_rules.deploy_files'
- python -c 'import manifest_rules.generate_environment_files'
- python -c 'import manifest_rules.generate_manifest_file'
......
......@@ -262,11 +262,11 @@ test-manifest:macos-64:
# Deploy/publish environment and manifest files.
# All deploy jobs must be manually invoked.
# Deployment destination is assumed to be
# available as a mount point at /releases/
# available as a mount point at
# /exports/fsldownloads/fslconda/releases/
.deploy-job-template:
stage: publish
image: continuumio/miniconda3
tags:
- fslconda-channel-host
when: manual
......@@ -291,3 +291,17 @@ deploy-release-manifest:
- generate-release-manifest-file
script:
- deploy_files /exports/fsldownloads/fslconda/releases/ ./manifest/*.json
# USE WITH CAUTION
#
# Clear files from the release folder.
# See manifest_rules/clear_release_files.py
# script for details.
clear-release-files:
extends: .deploy-job-template
variables:
PATTERN: ""
DRY_RUN: "true"
script:
- clear_release_files /exports/fsldownloads/fslconda/releases/ ${PATTERN} ${DRY_RUN}
#!/usr/bin/env python
__version__ = '0.5.3'
__version__ = '0.6.0'
#!/usr/bin/env python
#
# Remove files from the release directory according to a glob-style wildcard
# pattern. Can be used for development, experimentation, maintenance, or
# when mistakes happen.
#
# The PATTERN variable must be set to one or more glob- style wildcard
# patterns, separated with semi-colons, denoting the files that are to be
# removed. The DRY_RUN variable must be explicitly set to "false" for any
# files to actually be deleted.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import os.path as op
import os
import sys
import glob
def main():
release_dir = op.abspath(sys.argv[1])
patterns = sys.argv[2].split(';')
dry_run = sys.argv[3] != 'false'
print('Clearing release files')
print(f' release dir: {release_dir}')
print(f' patterns: {patterns}')
print(f' dry_run: {dry_run}')
for pattern in patterns:
pattern = op.join(release_dir, pattern.strip())
matches = glob.glob(pattern)
for match in matches:
print(f'Removing: {match}')
if not dry_run:
os.remove(match)
if __name__ == '__main__':
sys.exit(main())
......@@ -33,6 +33,7 @@ setup(
packages=find_packages(),
include_package_data=True,
entry_points={'console_scripts' : [
'clear_release_files = manifest_rules.clear_release_files:main',
'deploy_files = manifest_rules.deploy_files:main',
'generate_environment_files = manifest_rules.generate_environment_files:main',
'generate_manifest_file = manifest_rules.generate_manifest_file:main',
......
Markdown is supported
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