Skip to content

Commit fdebb69

Browse files
committed
Add script for building release binaries
1 parent bb74a3d commit fdebb69

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

RELEASING.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66

77
1. Create a tag on that commit with the format "x.y.z". Do not omit "z", even if its value is 0.
88

9-
1. Build the executables for the release (do this once on an x86_64 machine and once on an aarch64 one):
10-
11-
- In the root of the `swiftly` repository, run the following command: `docker build -t <image name> -f scripts/build.dockerfile .`
12-
- Then, run `container_id=$(docker create <image name>)`
13-
- Retrieve the built swiftly executable with `docker cp "$container_id:/swiftly" <executable name>`
14-
- For ARM, the executable name should be `swiftly-aarch64-unknown-linux-gnu`
15-
- For x86_64, the executable name should be `swiftly-x86_64-unknown-linux-gnu`
16-
- Clean up the leftover container with `docker rm -v $container_id`
17-
- Clean up the leftover image with `docker rm -f <image name>`
9+
1. Build the executables for the release by running ./scripts/build_release.sh from the root of the swiftly repository (do this once on an x86_64 machine and once on an aarch64 one)
1810

1911
1. Push the tag to `origin`.
2012

scripts/build_release.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
version="$1"
6+
7+
if [[ -z "$version" ]]; then
8+
echo "Usage: build.sh <version tag>"
9+
exit 1
10+
fi
11+
12+
raw_arch="$(uname --machine)"
13+
case "$raw_arch" in
14+
"x86_64")
15+
arch="x86_64"
16+
;;
17+
18+
"aarch64" | "arm64")
19+
arch="aarch64"
20+
;;
21+
22+
*)
23+
echo "Error: Unsupported CPU architecture: $RAW_ARCH"
24+
;;
25+
esac
26+
27+
git checkout "$version"
28+
29+
if [[ ! -z "$(git status --porcelain=v1 2>/dev/null)" ]]; then
30+
echo "There are uncommitted changes in the local tree, please commit or discard them"
31+
exit 1
32+
fi
33+
34+
image_name="swiftly-$version"
35+
binary_name="swiftly-$arch-unknown-linux-gnu"
36+
docker build -t "$image_name" -f scripts/build.dockerfile .
37+
container_id=$(docker create "$image_name")
38+
docker cp "$container_id:/swiftly" "$binary_name"
39+
docker rm -v "$container_id"
40+
docker image rm -f "$image_name"
41+
42+
"./$binary_name" --version > /dev/null
43+
44+
echo "$binary_name has been successfully built!"

0 commit comments

Comments
 (0)