version: '3' vars: PREPARE_DIRECTORY: | find . -type d -name ".git" -print0 | xargs -0 rm -rf find . -name ".gitignore" -print0 | xargs -0 rm -rf git init mv .drainpipeignore .gitignore # Override global gitignore git config core.excludesFile .gitignore git config core.attributesfile .gitattributes git add . git clean -ffdX rm .gitignore tasks: directory: desc: "Creates a snapshot of the current working directory" summary: | Creates a snapshot of the current working directory .git, .gitignore, files listed in .drainpipeignore, and .drainpipeignore itself are not added. .drainpipeignore uses the same format as gitignore. usage: task snapshot:directory directory=/tmp/release directory= Write the archive to cmds: - if [ -d "{{.directory}}" ] || [ "" == "{{.directory}}" ]; then echo "Please provide a path to a directory that does not yet exist" && exit 1; fi # Make sure any subdirectories exist - mkdir -p {{.directory}} && rm -rf {{.directory}} - cp -pR . {{.directory}} - if [ ! -f ".drainpipeignore" ]; then echo ".drainpipeignore does not exist" && touch {{.directory}}/.drainpipeignore; fi - | cd {{.directory}} {{ .PREPARE_DIRECTORY }} rm -rf .git archive: desc: "Creates a snapshot of the current working directory and exports as an archive" summary: | Creates a snapshot of the current working directory and exports as an archive. .git, .gitignore, files listed in .drainpipeignore, and .drainpipeignore itself are not added. .drainpipeignore uses the same format as gitignore. If your .gitattributes file contains export-ignore or export-subst, these will be respected when exporting the archive. usage: task snapshot:archive o=~/archive.tar.bz2 o= Write the archive to . The compression format is inferred from the file extension. Format options are: tar, tar.bz2, tar.gz, tar.xz, zip cmds: - | TMP_DIR=$(mktemp -d) cp -Rp . $TMP_DIR if [ ! -f ".drainpipeignore" ]; then echo ".drainpipeignore does not exist" && touch $TMP_DIR/.drainpipeignore; fi DESTINATION=$(realpath {{ .o }}) cd $TMP_DIR {{ .PREPARE_DIRECTORY }} git config user.email 'no-reply@lullabot.com' git config user.name 'Lullabot Drainpipe' git commit --quiet --message "Initial commit" --no-gpg-sign git config tar.tar.xz.command "xz --stdout --threads=0" git config tar.tar.bz2.command "bzip2 -c" git -C $TMP_DIR archive -o "$DESTINATION" HEAD test -f "$DESTINATION"