|
15 | 15 | # Get the latest commit message |
16 | 16 | COMMIT_MSG=$(git log -1 --pretty=%B) |
17 | 17 |
|
18 | | -log_title "Spine-Construct3 Build" |
| 18 | +log_title "Spine-Construct3 Deploy" |
19 | 19 | log_detail "Branch: $BRANCH" |
20 | 20 |
|
21 | | -log_action "Installing dependencies" |
22 | | -pushd ".." > /dev/null |
23 | | -if npm install > /tmp/npm-install.log 2>&1; then |
| 21 | +# Only deploy if the commit message matches [ts] Release x.y.z |
| 22 | +if ! echo "$COMMIT_MSG" | grep -qE '^\[ts\] Release [0-9]+\.[0-9]+\.[0-9]+$'; then |
| 23 | + log_warn "Commit is not a release - skipping deploy" |
| 24 | + log_detail "To deploy, commit message must be: \"[ts] Release x.y.z\"" |
| 25 | + log_summary "Deploy skipped" |
| 26 | + exit 0 |
| 27 | +fi |
| 28 | + |
| 29 | +VERSION=$(echo "$COMMIT_MSG" | sed -E 's/^\[ts\] Release ([0-9]+\.[0-9]+\.[0-9]+)$/\1/') |
| 30 | +log_detail "Version: $VERSION" |
| 31 | + |
| 32 | +if [ -z "$C3_UPDATE_URL" ] || [ -z "$BRANCH" ]; then |
| 33 | + log_skip "Deployment skipped (C3_UPDATE_URL and/or BRANCH not set)" |
| 34 | + log_summary "✓ Deploy skipped" |
| 35 | + exit 0 |
| 36 | +fi |
| 37 | + |
| 38 | +log_action "Creating .c3addon" |
| 39 | +pushd "dist" > /dev/null |
| 40 | +if ZIP_OUTPUT=$(zip -r ../EsotericSoftware_SpineConstruct3.c3addon ./* 2>&1); then |
24 | 41 | log_ok |
25 | 42 | else |
26 | 43 | log_fail |
27 | | - log_error_output "$(cat /tmp/npm-install.log)" |
| 44 | + log_error_output "$ZIP_OUTPUT" |
28 | 45 | exit 1 |
29 | 46 | fi |
30 | 47 | popd > /dev/null |
31 | 48 |
|
32 | | -# Public only if the commit message is in the correct format |
33 | | -if ! [ -z "$C3_UPDATE_URL" ] && ! [ -z "$BRANCH" ]; |
34 | | -then |
35 | | - log_action "Creating artifacts zip" |
36 | | - pushd "dist" > /dev/null |
37 | | - if ZIP_OUTPUT=$(zip -r ../EsotericSoftware_SpineConstruct3.c3addon ./* 2>&1); then |
38 | | - log_ok |
39 | | - popd > /dev/null |
40 | | - if ZIP_OUTPUT=$(zip spine-construct3.zip EsotericSoftware_SpineConstruct3.c3addon 2>&1); then |
41 | | - log_ok |
42 | | - else |
43 | | - log_fail |
44 | | - log_error_output "$ZIP_OUTPUT" |
45 | | - exit 1 |
46 | | - fi |
47 | | - else |
48 | | - log_fail |
49 | | - log_error_output "$ZIP_OUTPUT" |
50 | | - exit 1 |
51 | | - fi |
| 49 | +log_action "Creating versioned zip: spine-construct3-$VERSION.zip" |
| 50 | +if ZIP_OUTPUT=$(zip "spine-construct3-$VERSION.zip" EsotericSoftware_SpineConstruct3.c3addon 2>&1); then |
| 51 | + log_ok |
| 52 | +else |
| 53 | + log_fail |
| 54 | + log_error_output "$ZIP_OUTPUT" |
| 55 | + exit 1 |
| 56 | +fi |
52 | 57 |
|
53 | | - log_action "Uploading to $C3_UPDATE_URL$BRANCH" |
54 | | - if CURL_OUTPUT=$(curl -f -F "file=@spine-construct3.zip" "$C3_UPDATE_URL$BRANCH" 2>&1); then |
55 | | - log_ok |
56 | | - else |
57 | | - log_fail |
58 | | - log_error_output "$CURL_OUTPUT" |
59 | | - exit 1 |
60 | | - fi |
| 58 | +log_action "Creating latest zip: spine-construct3.zip" |
| 59 | +if CP_OUTPUT=$(cp "spine-construct3-$VERSION.zip" spine-construct3.zip 2>&1); then |
| 60 | + log_ok |
| 61 | +else |
| 62 | + log_fail |
| 63 | + log_error_output "$CP_OUTPUT" |
| 64 | + exit 1 |
| 65 | +fi |
61 | 66 |
|
62 | | - log_summary "✓ Build and deployment successful" |
| 67 | +log_action "Uploading spine-construct3-$VERSION.zip to $C3_UPDATE_URL$BRANCH" |
| 68 | +if CURL_OUTPUT=$(curl -f -F "file=@spine-construct3-$VERSION.zip" "$C3_UPDATE_URL$BRANCH" 2>&1); then |
| 69 | + log_ok |
63 | 70 | else |
64 | | - log_skip "Deployment skipped (C3_UPDATE_URL and/or BRANCH not set)" |
65 | | - log_summary "✓ Build successful" |
| 71 | + log_fail |
| 72 | + log_error_output "$CURL_OUTPUT" |
| 73 | + exit 1 |
66 | 74 | fi |
| 75 | + |
| 76 | +log_action "Uploading spine-construct3.zip (latest) to $C3_UPDATE_URL$BRANCH" |
| 77 | +if CURL_OUTPUT=$(curl -f -F "file=@spine-construct3.zip" "$C3_UPDATE_URL$BRANCH" 2>&1); then |
| 78 | + log_ok |
| 79 | +else |
| 80 | + log_fail |
| 81 | + log_error_output "$CURL_OUTPUT" |
| 82 | + exit 1 |
| 83 | +fi |
| 84 | + |
| 85 | +log_summary "✓ Construct3 plugin $VERSION deployed successfully" |
0 commit comments