-
Notifications
You must be signed in to change notification settings - Fork 14
/
snapshot.yml
69 lines (59 loc) · 2.69 KB
/
snapshot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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=<file> Write the archive to <file>
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=<file> Write the archive to <file>. 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 '[email protected]'
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"