-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtk_core_update.sh
executable file
·104 lines (89 loc) · 2.8 KB
/
tk_core_update.sh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
#
# Copyright (c) 2015 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
echo "This script will update the local repository with the given version of the TK-CORE."
echo ""
echo "Script syntax: $0 tk-core-tag"
echo "For example: $0 v0.20.17"
echo ""
echo ""
echo "A commit_id file will be written to the tk-core shotgun distribution to "
echo "indicate which version being bundled with core."
echo ""
echo "This script is intended to be used by developers and maintainers of the tk-core API."
echo ""
echo "Note requires sed on Linux or gsed on MacOS."
echo ""
echo ""
echo ""
# Stops the script
set -e
# Where we'll temporary create some files.
ROOT="/var/tmp/tmp_dir_$(date +%y.%m.%d.%H.%M.%S)"
abort()
{
echo >&2 '
***************
*** ABORTED ***
***************
'
echo "Cleaning up $ROOT..." >&2
rm -rf "$ROOT"
exit 1
}
trap 'abort' 0
# Git repo we'll clone
[email protected]:shotgunsoftware/tk-core.git
# Where we'll clone the repo
DEST_REPO="$ROOT/repo"
# Destination relative to this script for the files
DEST="$(pwd)/python/tk-core"
# Recreate the folder structure
mkdir "$ROOT"
mkdir "$DEST_REPO"
# Strip files from the destination and recreate it.
rm -rf "$DEST"
mkdir -p "$DEST"
echo "Cloning TK-CORE into a temp location, hang on..."
# Clone the repo
git clone "$SRC_REPO" "$DEST_REPO" --depth=1 -b "$1"
echo "Copying TK-CORE to the required location..."
# Move to the git repo to generate the sha and write it to the $DEST
git -C "$DEST_REPO" rev-parse HEAD > "$DEST/commit_id"
# Copy the files to the destination, but not the tests
cp -R "$DEST_REPO"/* "$DEST"
rm -rf "$DEST/tests"
rm -rf "$DEST/docs"
echo "Updating tk-core info.yml..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed -i "$DEST/info.yml" -e "s/version: \"HEAD\"/version: \"$1\"/"
elif [[ "$OSTYPE" == "darwin"* ]]; then
if hash gsed 2>/dev/null; then
gsed -i "$DEST/info.yml" -e "s/version: \"HEAD\"/version: \"$1\"/"
else
echo "gsed not found, please install it using brew install gnu-sed"
exit 1
fi
else
echo "This script should run on Linux or MacOS only."
exit 1
fi
cp python/tk-core/software_credits software_credits
git add software_credits
# Put files in the staging area.
echo "adding new files to git..."
git add -A "$DEST"
# Cleanup!
rm -rf "$ROOT"
echo ""
echo "All done! TK-CORE in $DEST has been updated to $1."
echo "The changes have been added to git and are ready to be committed."
trap : 0