-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·74 lines (59 loc) · 1.81 KB
/
package.sh
File metadata and controls
executable file
·74 lines (59 loc) · 1.81 KB
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
#!/bin/bash
# packaging up for deposit at openICPSR.
# Note that we do this from within the directory, so as not to have redundant directory levels.
# Usage: ./package.sh [DATE]
# If DATE is not provided, uses the last git commit date
set -e
repo=processing-jira-process-data
pwd=$(pwd)
# Determine date to use
if [ -z "$1" ]; then
# Get last commit date in YYYY-MM-DD format
DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d)
echo "No date provided. Using last commit date: $DATE"
else
DATE="$1"
echo "Using provided date: $DATE"
fi
if [ "${pwd##*/}" == "$repo" ]
then
echo "Processing ZIP creation"
git pull
git lfs pull
zipfile="../${repo}-${DATE}.zip"
echo "Creating archive: $zipfile"
zip -rp "$zipfile" README.md
zip -rp "$zipfile" LICENSE.txt
zip -rp "$zipfile" README.pdf
zip -rp "$zipfile" programs/
zip -rp "$zipfile" images/
zip -rp "$zipfile" data/anon/
zip -rp "$zipfile" data/metadata
echo "Archive created successfully: $zipfile"
# Create git tag
tag_name="data-${DATE}"
commit_message="Data and code as of ${DATE}"
echo "Creating git tag: $tag_name"
if git rev-parse "$tag_name" >/dev/null 2>&1; then
echo "Warning: Tag $tag_name already exists. Skipping tag creation."
read -p "Do you want to delete and recreate the tag? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git tag -d "$tag_name"
git tag -a "$tag_name" -m "$commit_message"
echo "Tag recreated: $tag_name"
fi
else
git tag -a "$tag_name" -m "$commit_message"
echo "Tag created: $tag_name with message: $commit_message"
fi
echo ""
echo "Summary:"
echo " Archive: $zipfile"
echo " Tag: $tag_name"
echo " Message: $commit_message"
echo ""
echo "To push the tag to remote, run: git push origin $tag_name"
else
echo "Skipping processing. Be sure to be inside the repo $repo"
fi