-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-release
executable file
·30 lines (24 loc) · 999 Bytes
/
make-release
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
#!/bin/sh
set -euC;
RELEASE_DIR="release/";
# Copy the release artifacts to the release directory.
rm -rf "$RELEASE_DIR";
mkdir -p "$RELEASE_DIR";
cp src/user-mirror "$RELEASE_DIR";
cp src/image/entrypoint "$RELEASE_DIR";
# Attempt to set the version based off of the previous "release-x.x.x" tag.
# Otherwise, just use the current commit.
if last_release_tag="$(git describe --tags --abbrev=0 --match=release-*)" 2>/dev/null; then
VERSION="$(echo "$last_release_tag" | cut -c 9-)-$(git rev-parse --short HEAD)";
else
VERSION="$(git rev-parse HEAD)";
fi
# Create version file
printf "$VERSION" > "$RELEASE_DIR/version"
# Replace VERSION= in the scripts with the release version.
(cd "$RELEASE_DIR" && sed -i -e "s/VERSION='development';/VERSION='$VERSION';/" *);
if command -v shellcheck >/dev/null; then
(cd "$RELEASE_DIR" && \
grep -e '^#!/bin/sh' --exclude-dir=.git -lR | xargs shellcheck --shell=sh --severity=warning);
fi
echo "Release $VERSION generated in $RELEASE_DIR";