Skip to content

Commit

Permalink
Add a script to generate release artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
lthms committed Dec 29, 2023
1 parent 510d591 commit 7057f15
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_build/
_opam/
_artifacts/
*.install
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ with the following command.
yay -S spatial-shell
```

### Official Binary Builds

Starting with Spatial Shell 5th release, binary builds are attached to GitHub
releases for Linux (x86_64).

Signatures are provided as well. The maintainer public key is
[`320E11CB5316864648593D5E14CD43A3866E4C18`][pubkey].

## Getting Started

### Configuring Your Favorite WM
Expand Down Expand Up @@ -151,3 +159,4 @@ of this project, including for the wording of several man pages.
[min-config]: ./contrib/sway/spatial.conf
[waybar]: https://github.com/Alexays/Waybar
[contrib-dir]: ./contrib/
[pubkey]: https://soap.coffee/~lthms/files/lthms@soap.coffee.pub
77 changes: 77 additions & 0 deletions scripts/prepare-release-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/sh

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/. *)

set -e

function usage() {
echo "Usage: ${0} [-s EMAIL]" 1>&2
exit 1
}

local_user=""

while getopts "s:" o; do
case "${o}" in
s)
local_user=${OPTARG}
;;
*)
usage
;;
esac
done

function spatial_version() {
grep '^version:' spatial-shell.opam | sed 's/version: "\(.*\)"/\1/'
}

echo "Building artifacts for spatial-shell-$(spatial_version)"

if [ ! -z "$(git status -s)" ]; then
echo "You have uncommitted changes. Press enter to continue."
read

if [ ! "$?" = "0" ]; then
exit 1
fi
fi

release_name="spatial-shell-$(spatial_version)"
archive_suffix="-linux-$(uname -m).tar.gz"
worktree=$(git rev-parse --show-toplevel)
tmp_workspace="$(mktemp -d)"

if [ -f "_artifacts/${release_name}${archive_suffix}" ]; then
echo "_artifacts/${release_name}${archive_suffix} already exists. You need to delete it to run this script."
exit 2
fi

# Building a static distribution

pushd "${tmp_workspace}"
git clone -q "${worktree}" .
OCAML_COMPILER=ocaml-option-static,ocaml-option-no-compression,ocaml.5.1.1 make build-deps
eval $(opam env)
BUILD_PROFILE=static DESTDIR=artifacts make install
opam switch remove . -y
popd
mkdir -p _artifacts
mv "${tmp_workspace}/artifacts" "_artifacts/${release_name}"

# Creating the archive

rm -rf "${tmp_workspace}"
pushd _artifacts
tar czvf "${release_name}${archive_suffix}" "${release_name}"
rm -rf ${release_name}

if [ -n "${local_user}" ]; then
gpg --local-user "${local_user}" \
--out "${release_name}${archive_suffix}.sig" \
--detach-sig "${release_name}${archive_suffix}"
fi

popd

0 comments on commit 7057f15

Please sign in to comment.