-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_release
More file actions
executable file
·40 lines (34 loc) · 948 Bytes
/
build_release
File metadata and controls
executable file
·40 lines (34 loc) · 948 Bytes
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
#!/usr/bin/env bash
set -u
set -e
if ! git diff --cached --exit-code --quiet
then
>&2 echo "Can't release when there are staged changes"
exit 1
fi
# This must be run from the repo root directory
cd "$(dirname "$0")"
NAME="twodina"
cargo build --release
rm -rf "${NAME:-/tmp/foo}" "${NAME:-/tmp/foo}.zip"
mkdir -p "$NAME"
cp "target/release/$NAME" "$NAME/"
# Copy assets.
for asset in $(git ls-files assets)
do
asset_dir="$(dirname "$asset")"
mkdir -p "$NAME/$asset_dir"
cp "$asset" "$NAME/$asset_dir/"
done
# Add the commit hash.
git show -q --format=format:%H > "$NAME/commit.txt"
# Create a branch and commit the release.
branch="release-$(date '+%Y-%m-%d-%H%M%S')"
git checkout -b "$branch"
git add -f "$NAME"
git commit -m "Release"
# Use git to zip since we can't rely on external dependencies.
git archive --format=zip -o "$NAME.zip" HEAD "$NAME"
# Restore state and clean up.
git checkout -
git branch -D "$branch"