forked from pgxn/docker-pgxn-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpgxn-bundle
executable file
·35 lines (31 loc) · 1.13 KB
/
pgxn-bundle
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
#!/bin/bash
set -eu
# First check that the meta file is valid.
if [ -e META.json ]; then
echo Validating META.json...
pgxn validate-meta META.json
else
echo 'ERROR: No META.json file'
echo 'DETAIL: See http://manager.pgxn.org/howto for how to create a PGXN'
echo ' distribution, including the required META.json file.'
exit 2
fi
# Get the extension name and version.
DISTNAME=${PGXN_DIST_NAME:-$(perl -MJSON=decode_json -E 'say decode_json(join "", <>)->{name}' META.json)}
VERSION=${PGXN_DIST_VERSION:-$(perl -MJSON=decode_json -E 'say decode_json(join "", <>)->{version}' META.json)}
# Now bundle up the distribution for release.
release=${DISTNAME}-${VERSION}
echo "Bundling $release.zip..."
if [ true == "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
git archive --format zip --prefix=${release}/ --output ${release}.zip HEAD
else
mkdir /tmp/$release
cp -rf . /tmp/$release
(cd /tmp && zip -r $release.zip $release)
mv /tmp/$release.zip .
fi
if [[ -n "${GITHUB_OUTPUT-}" ]]; then
echo "bundle=$release.zip" >> $GITHUB_OUTPUT
else
echo "::set-output name=bundle::$release.zip"
fi