-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.dist.yaml
85 lines (85 loc) · 2.79 KB
/
Taskfile.dist.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
version: "3"
env:
WORKING_DIR: '{{.WORKING_DIR | default "."}}'
# dotenv: [.env]
includes:
pre-commit:
taskfile: "./contrib/tasks/pre-commit/Taskfile.yaml"
aliases: [pc]
docker:
taskfile: "./contrib/tasks/docker/Taskfile.yaml"
aliases: [d]
utils:
taskfile: ./contrib/tasks/utils/Taskfile.yaml
internal: true
# ──────────────────────────────────────────────────────────────────────────────
tasks:
default:
silent: true
deps:
- pre-commit:install
cmds:
- task: utils:default
clean:
aliases: [c]
cmds:
- task: utils:trash
for:
- "*.spdx.json"
vars:
TARGET_PATH: "{{.ITEM}}"
- defer: {task: "utils:trash"}
vars:
TARGET_PATH: ".task"
snapshot:
aliases: [s]
# deps: [clean]
cmds:
- cmd: |
powershell -c '
$tmp = New-TemporaryFile ;
Remove-Item "$tmp" ;
New-Item -Path "$tmp" -ItemType Directory | Out-Null ;
$time=Get-Date -UFormat "%Y-%m-%d-%H-%M" ;
$snapshot_dir="{{.ROOT_DIR}}/tmp/snapshots" ;
$path="${snapshot_dir}/${time}.zip" ;
If(!(test-path -PathType container "$(Split-Path "$path")"))
{
New-Item -ItemType Directory -Path "$(Split-Path "$path")" ;
}
$ExtensionsToExclude = "*.exe","*.pdf","*.tar","*.gz","*.zip" ;
$PathsToExclude = "(.git|tmp|node_modules)" ;
Get-ChildItem `
-Recurse `
-Exclude $ExtensionsToExclude `
-Path "{{.ROOT_DIR}}" `
| Where-Object { $_.FullName -notmatch $PathsToExclude } `
| Compress-Archive -DestinationPath "$path" -Update ;
'
platforms: [windows]
- cmd: |
tmp="$(mktemp -d)" ;
time="$(date +'%Y-%m-%d-%H-%M')" ;
snapshot_dir="{{.ROOT_DIR}}/tmp/snapshots" ;
path="${snapshot_dir}/${time}.tar.gz" ;
sync ;
mkdir -p "${snapshot_dir}" ;
tar -C "{{.ROOT_DIR}}" --exclude-vcs -cpzf "${tmp}/${time}.tar.gz" .
mv "${tmp}/${time}.tar.gz" "${path}" ;
rm -rf "${tmp}" ;
gunzip --force "${path}" ;
exlude_list=(
"./.git/"
"./tmp"
) ;
for path in "${exlude_list[@]}";do
if tar --list --file "${snapshot_dir}/${time}.tar" "${path}" > /dev/null 2>&1 ; then
tar \
--file "${snapshot_dir}/${time}.tar" \
--delete "${path}" ;
fi
done
gzip "${snapshot_dir}/${time}.tar" ;
echo "*** snapshot created at ${path}" ;
platforms: [linux, darwin]