-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from shakacode/linux-arm64
Add linux arm64 binary
- Loading branch information
Showing
9 changed files
with
172 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
export $(cat scripts/aws.env | xargs) | ||
|
||
ARCH="aarch64" | ||
PLATFORM="linux" | ||
|
||
BIN="$LIB-$PLATFORM-$ARCH.exe" | ||
REMOTE_BIN="~/re-formality/$RELEASE_DIR/$BIN" | ||
RELEASE_BIN="$RELEASE_BIN_DIR/$BIN" | ||
|
||
echo "" | ||
echo "=== Preparing $PLATFORM $ARCH binary" | ||
|
||
echo "Creating EC2 instance" | ||
INSTANCE_ID=$( | ||
aws ec2 run-instances \ | ||
--image-id ami-0f69dd1d0d03ad669 \ | ||
--count 1 \ | ||
--instance-type m6g.medium \ | ||
--key-name re-formality \ | ||
--user-data file://scripts/user-data.linux-arm64.sh \ | ||
--tag-specifications="ResourceType=instance,Tags=[{Key=re-formality,Value=''}]" \ | ||
| jq -r ".Instances[0].InstanceId" | ||
) | ||
echo "EC2 instance $INSTANCE_ID created" | ||
|
||
echo "Getting public IP" | ||
while : | ||
do | ||
INSTANCE_IP=$( | ||
aws ec2 describe-instances --instance-ids $INSTANCE_ID | jq -r ".Reservations[0].Instances[0].PublicIpAddress" | ||
) | ||
if [ -n "$INSTANCE_IP" ]; | ||
then | ||
echo "Instance is available at $INSTANCE_IP" | ||
break; | ||
else | ||
sleep 5; | ||
fi | ||
done | ||
|
||
echo "Waiting for the build to complete" | ||
|
||
sleep 300 | ||
|
||
USER="ubuntu" | ||
|
||
while : | ||
do | ||
if ssh -o StrictHostKeyChecking=no -q -i scripts/aws.pem $USER@$INSTANCE_IP test -f "$REMOTE_BIN"; | ||
then | ||
echo "Binary is ready. Downloading." | ||
break | ||
else | ||
sleep 5 | ||
fi | ||
done | ||
|
||
scp -i scripts/aws.pem $USER@$INSTANCE_IP:$REMOTE_BIN $RELEASE_BIN | ||
echo "Downloaded." | ||
|
||
chmod $CHMOD $RELEASE_BIN | ||
|
||
echo "Terminating instance." | ||
aws ec2 terminate-instances --instance-ids $INSTANCE_ID | ||
echo "Instance terminated." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
ARCH=$(uname -m) | ||
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
|
||
echo "" | ||
echo "=== Preparing $PLATFORM $ARCH binary" | ||
|
||
SOURCE_BIN="_build/default/ppx/bin/bin.exe" | ||
RELEASE_BIN="$RELEASE_BIN_DIR/$LIB-$PLATFORM-$ARCH.exe" | ||
|
||
dune build | ||
cp $SOURCE_BIN $RELEASE_BIN | ||
chmod $CHMOD $RELEASE_BIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
OPAM_FILE=$(basename -- "$(find *.opam)") | ||
|
||
export LIB="${OPAM_FILE%.*}" | ||
export RELEASE_DIR="_release" | ||
export RELEASE_ZIP="$RELEASE_DIR/release.zip" | ||
export RELEASE_BIN_DIR="$RELEASE_DIR/bin" | ||
|
||
echo "=== Releasing $LIB" | ||
|
||
if [ ! -f "$RELEASE_ZIP" ]; then | ||
echo "$RELEASE_ZIP does not exist. Download it from Github and put in $RELEASE_DIR/ dir." | ||
exit 1 | ||
fi | ||
|
||
echo "=== Unzipping release archive" | ||
unzip -d $RELEASE_DIR $RELEASE_ZIP | ||
rm $RELEASE_ZIP | ||
|
||
echo "Release tree:" | ||
tree -a -L 2 $RELEASE_DIR | ||
|
||
export CHMOD=$(stat -c %a "$RELEASE_BIN_DIR/$(ls $RELEASE_BIN_DIR | head -n 1)") | ||
|
||
./scripts/build-macos-arm64.sh | ||
./scripts/build-linux-arm64.sh | ||
|
||
echo "Release tree:" | ||
tree -a -L 2 $RELEASE_DIR | ||
|
||
echo "" | ||
echo "=== Publishing to npm" | ||
cd $RELEASE_DIR | ||
rm .DS_Store >/dev/null 2>&1 || true | ||
|
||
echo "package.json:" | ||
cat package.json | ||
echo "" | ||
|
||
npm publish | ||
cd .. | ||
|
||
echo "" | ||
echo "=== Cleaning up" | ||
rm -rf $RELEASE_DIR/* | ||
tree -a -L 2 $RELEASE_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt update | ||
apt install opam -y | ||
|
||
sudo -u ubuntu bash -xec 'pwd; | ||
OCAML_VERSION=4.12.0; | ||
opam init --no; | ||
opam switch create $OCAML_VERSION; | ||
eval $(opam env --switch=$OCAML_VERSION); | ||
opam install -y dune ppxlib reason alcotest; | ||
cd ~; | ||
git clone https://github.com/shakacode/re-formality.git; | ||
cd re-formality; | ||
dune build; | ||
ARCH=$(uname -m); | ||
PLATFORM=$(uname -s | tr "[:upper:]" "[:lower:]"); | ||
OPAM_FILE=$(basename -- $(find *.opam)); | ||
LIB="${OPAM_FILE%.*}"; | ||
SOURCE_BIN="_build/default/ppx/bin/bin.exe"; | ||
RELEASE_BIN="_release/$LIB-$PLATFORM-$ARCH.exe"; | ||
mkdir -p $(dirname $RELEASE_BIN); | ||
cp $SOURCE_BIN $RELEASE_BIN; | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ mkShell { | |
ocaml-lsp | ||
nodejs | ||
yarn | ||
awscli2 | ||
darwin.apple_sdk.frameworks.CoreServices | ||
]; | ||
} |