-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathentrypoint.sh
executable file
·104 lines (85 loc) · 2.54 KB
/
entrypoint.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
#!/bin/bash
function setup() {
echo "::group::Set up environment"
# If the TS_PATH var is set and not empty
if [ -n "$TS_PATH" ]; then
echo "::debug::TS_PATH found"
p=$(echo $TS_PATH | sed 's:$/*::') #trim any trailing '/'
else
echo "::debug::TS_PATH not set"
p="."
fi
mkdir -p "/dist"
# Move files to the dist directory for the tcli
echo "Move files from $p to /dist"
mv $p/* /dist
# Move the README if it exists
if [ -e "/dist/README.md" ]; then
echo "Move README"
mv "/dist/README.md" "/"
elif [ -n "$TS_README" ]; then
echo "Download README from $TS_README"
wget -O "/README.md" "$TS_README"
fi
if [ -e "/dist/icon.png" ]; then
echo "Move icon"
mv "/dist/icon.png" "/"
elif [ -n "$TS_ICON" ]; then
echo "Download icon from $TS_ICON"
wget -O "/icon.png" "$TS_ICON"
fi
if [ -e "/dist/CHANGELOG.md" ]; then
echo "Move CHANGELOG"
mv "/dist/CHANGELOG.md" "/"
elif [ -n "$TS_CHANGELOG" ]; then
echo "Download CHANGELOG from $TS_CHANGELOG"
wget -O "/CHANGELOG.md" "$TS_CHANGELOG"
fi
echo "::endgroup::"
}
function configure(){
cd "/"
echo "::group::Configure tcli"
#tcli usage based off of https://github.com/R2Northstar/Northstar/blob/d8ad8f12f8bca1e8de96f5d7163f71997d487218/.github/workflows/build.yml#L132-L192
echo "Init tcli config"
tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION#v}
deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js
echo "Done config edit"
echo
echo "::debug::$(cat thunderstore.toml)"
echo "::endgroup::"
}
function publish() {
if [ -n "$TS_DEV" ]; then
repo="https://thunderstore.dev"
elif [ -n "$TS_REPO" ]; then
repo="https://thunderstore.io"
else
repo="$TS_REPO"
fi
# skip the build if there is a prebuilt package provided
if [ -n "$TS_FILE" ]; then
echo "::group::Publish package"
echo "Publish to $repo"
file="dist/$TS_FILE"
else
echo "::group::Build and publish"
tcli build
echo "Publish to $repo"
file="build/*.zip"
fi
out=$(tcli publish --repository ${repo} --file ${file}) #capture the output to get the URL
# A bad response from the server doesn't exit with a non-zero status code
if [[ $? -ne 0 ]]; then
echo "::error::$(echo ${out} | grep -Eo ERROR:.*)"
exit 1
fi
echo "url=$(echo ${out} | grep -Eo "https.*")" >> $GITHUB_OUTPUT
echo "Done!"
echo "::endgroup::"
}
set -e
setup
configure
set +e # Turn this off so we can see the output from tcli publish
publish