forked from slowli/externref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·57 lines (49 loc) · 1.35 KB
/
package.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
#!/usr/bin/env bash
# Script to create an archive with the release contents (the `externref` executable
# and the supporting docs).
set -e
VERSION=$1
if [[ "$VERSION" == '' ]]; then
echo "Error: release version is not specified"
exit 1
fi
echo "Packaging externref $VERSION for $TARGET..."
CLI_DIR=$(dirname "$0")
RELEASE_DIR="$CLI_DIR/release"
ROOT_DIR="$CLI_DIR/../.."
EXECUTABLE="$ROOT_DIR/target/$TARGET/executable/externref"
if [[ "$OS" == 'windows-latest' ]]; then
EXECUTABLE="$EXECUTABLE.exe"
fi
if [[ ! -x $EXECUTABLE ]]; then
echo "Error: executable $EXECUTABLE does not exist"
exit 1
fi
rm -rf "$RELEASE_DIR" && mkdir "$RELEASE_DIR"
echo "Copying release files to $RELEASE_DIR..."
cp "$EXECUTABLE" \
"$CLI_DIR/README.md" \
"$CLI_DIR/CHANGELOG.md" \
"$CLI_DIR/LICENSE-APACHE" \
"$CLI_DIR/LICENSE-MIT" \
"$RELEASE_DIR"
cd "$RELEASE_DIR"
echo "Creating release archive..."
case $OS in
ubuntu-latest | macos-latest)
ARCHIVE="externref-$VERSION-$TARGET.tar.gz"
tar czf "$ARCHIVE" ./*
;;
windows-latest)
ARCHIVE="externref-$VERSION-$TARGET.zip"
7z a "$ARCHIVE" ./*
;;
*)
echo "Unknown target: $TARGET"
exit 1
esac
ls -l "$ARCHIVE"
if [[ "$GITHUB_OUTPUT" != '' ]]; then
echo "Outputting path to archive as GitHub step output: $RELEASE_DIR/$ARCHIVE"
echo "archive=$RELEASE_DIR/$ARCHIVE" >> "$GITHUB_OUTPUT"
fi