build(package): added package script
package script auto generates release archive
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -103,3 +103,7 @@ output/
|
||||
scratch/
|
||||
|
||||
releases/
|
||||
stroid-dist/
|
||||
stroid-universal-dist.tar.gz
|
||||
stroid-*/
|
||||
stroid-*.tar.gz
|
||||
|
||||
114
package_release.sh
Executable file
114
package_release.sh
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RELEASE_DIR="releases"
|
||||
STAGING_DIR="stroid-dist"
|
||||
|
||||
REQUIRED_BINARIES=(
|
||||
"stroid-macos-arm64"
|
||||
"stroid-linux-x86_64"
|
||||
"stroid-linux-arm64"
|
||||
)
|
||||
|
||||
for bin in "${REQUIRED_BINARIES[@]}"; do
|
||||
if [ ! -f "$RELEASE_DIR/$bin" ]; then
|
||||
echo "Error: Missing binary $RELEASE_DIR/$bin. Run release.sh first."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
chmod +x "$RELEASE_DIR/stroid-macos-arm64"
|
||||
VERSION_OUTPUT=$("$RELEASE_DIR/stroid-macos-arm64" info -v)
|
||||
VERSION=$(echo "$VERSION_OUTPUT" | awk '{print $3}')
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Error: Could not extract version from binary output."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARBALL_NAME="stroid-${VERSION}.tar.gz"
|
||||
|
||||
echo "Packaging Stroid version ${VERSION}..."
|
||||
|
||||
rm -rf "$STAGING_DIR"
|
||||
mkdir -p "$STAGING_DIR/bin"
|
||||
|
||||
for bin in "${REQUIRED_BINARIES[@]}"; do
|
||||
cp "$RELEASE_DIR/$bin" "$STAGING_DIR/bin/"
|
||||
done
|
||||
|
||||
cat << 'EOF' > "$STAGING_DIR/install.sh"
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
OS=$(uname -s)
|
||||
ARCH=$(uname -m)
|
||||
INSTALL_PATH=$1
|
||||
|
||||
echo "Detecting system: $OS ($ARCH)"
|
||||
|
||||
case "$OS" in
|
||||
Darwin)
|
||||
if [ "$ARCH" = "arm64" ]; then
|
||||
SELECTED_BIN="bin/stroid-macos-arm64"
|
||||
else
|
||||
echo "Error: Intel Macs (x86_64) are not supported by this package."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
Linux)
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
SELECTED_BIN="bin/stroid-linux-x86_64"
|
||||
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||
SELECTED_BIN="bin/stroid-linux-arm64"
|
||||
else
|
||||
echo "Error: Linux architecture $ARCH is not supported."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Error: Operating system $OS is not supported."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Verifying binary integrity..."
|
||||
chmod +x "$SELECTED_BIN"
|
||||
if ! ./"$SELECTED_BIN" info -v > /dev/null 2>&1; then
|
||||
echo "Error: The selected binary failed the version check. It may be incompatible with this system's libraries."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION_INFO=$(./"$SELECTED_BIN" info -v)
|
||||
echo "Verification successful: $VERSION_INFO"
|
||||
|
||||
if [ -z "$INSTALL_PATH" ]; then
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
INSTALL_PATH="/usr/local/bin"
|
||||
else
|
||||
INSTALL_PATH="$HOME/.local/bin"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$INSTALL_PATH"
|
||||
|
||||
echo "Installing to: $INSTALL_PATH/stroid"
|
||||
cp "$SELECTED_BIN" "$INSTALL_PATH/stroid"
|
||||
chmod +x "$INSTALL_PATH/stroid"
|
||||
|
||||
echo "Installation complete."
|
||||
if [[ ":$PATH:" != *":$INSTALL_PATH:"* ]]; then
|
||||
echo "Note: $INSTALL_PATH is not in your PATH. Add it to your shell profile to run 'stroid' from anywhere."
|
||||
fi
|
||||
EOF
|
||||
|
||||
chmod +x "$STAGING_DIR/install.sh"
|
||||
|
||||
tar -czf "$TARBALL_NAME" -C "$STAGING_DIR" .
|
||||
|
||||
echo "Distribution package created: $TARBALL_NAME"
|
||||
echo "Contents:"
|
||||
tar -tf "$TARBALL_NAME"
|
||||
|
||||
rm -rf "$STAGING_DIR"
|
||||
44
release.md
Normal file
44
release.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Generating Releases
|
||||
|
||||
> This document is likely only of interest to developers wishing to build release files. If you wish to use
|
||||
> stroid, please refer to the main readme instructions.
|
||||
|
||||
## Building
|
||||
Release files can be built on an arm mac using the following commands:
|
||||
|
||||
```bash
|
||||
./release.sh
|
||||
```
|
||||
|
||||
all release files will be placed in the `releases/` folder.
|
||||
|
||||
This will construct release files for arm mac, arm linux, and x86_64 linux. These should be
|
||||
compatible with most systems (linux more recent than 2020 and macOS more recent than 15.0)
|
||||
|
||||
For those who wish to build from source see the main readme instructions.
|
||||
|
||||
## Packaging
|
||||
The auto-generated release files are named according to the following convention:
|
||||
`stroid-<os>-<arch>`, these are all statically linked so they should
|
||||
just run on system. To distribute these files we want to package them into a single
|
||||
archive file along with an installation script which will select the correct binary
|
||||
for the host system. There is a script `package_release.sh` which will do this automatically.
|
||||
|
||||
Once the release files have been generated, run the following command:
|
||||
|
||||
```bash
|
||||
./package_release.sh
|
||||
```
|
||||
|
||||
## Uploading
|
||||
Once the release files have been packaged, they can be uploaded to the github releases page. This can be done manually through the github web interface, or
|
||||
automatically using the `gh` CLI tool. To upload using the CLI tool, first ensure you have it installed and authenticated with your
|
||||
github account. Then run the following command:
|
||||
|
||||
```bash
|
||||
gh release create <tag> ./stroid-release.tar.gz
|
||||
```
|
||||
|
||||
Alternatively, you can upload the files manually through the github web interface by navigating to the releases page of
|
||||
the repository and clicking on "Draft a new release". From there, you can upload the `stroid-release.tar.gz` file and
|
||||
publish the release.
|
||||
Reference in New Issue
Block a user