Commit cc3bbb6e authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

ENH: Script/job to clean up release dir

parent dd01090c
......@@ -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
#
# 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())
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