Skip to content

Commit

Permalink
feat(nano): add version to binary compilation, upload, and download l…
Browse files Browse the repository at this point in the history
…ogic

BREAKING CHANGE: the binaries are no longer overwritten in s3 on every publish.
This will allow for each version of hyper-nano to use a specific unchanging binary
  • Loading branch information
TillaTheHun0 committed May 30, 2023
1 parent 7547026 commit 805272b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/image-nano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
- name: 🛠 Build Executables
run: |
cd images/nano
export VER=$(node -e "console.log(require('./package.json').version)")
echo "binary version: $VER"
make clean compile-linux compile-apple compile-arch-apple compile-windows
env:
CI: true
Expand All @@ -70,8 +73,10 @@ jobs:
- name: 🗄 Upload Executables to S3
run: |
cd images/nano
echo "aliasing linux binary to 'hyper'"
cp ./build/hyper-x86_64-unknown-linux-gnu ./build/hyper
echo "aliasing latest linux binary to 'hyper'"
export VER=$(node -e "console.log(require('./package.json').version)")
echo "binary version: $VER"
cp ./build/hyper-x86_64-unknown-linux-gnu-$VER ./build/hyper
echo "copying binaries to hyperland s3 ⚡️"
aws s3 cp --acl public-read --recursive ./build s3://hyperland
Expand Down
20 changes: 16 additions & 4 deletions images/nano/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@ clean:
@rm -rf ./build

compile-linux:
@deno compile --target=x86_64-unknown-linux-gnu --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net --unstable --no-check=remote --output ./build/hyper-x86_64-unknown-linux-gnu mod.js
@deno compile --target=x86_64-unknown-linux-gnu \
--allow-sys --allow-env --allow-read --allow-write=__hyper__ --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-unknown-linux-gnu-$(VER) mod.js

compile-apple:
@deno compile --target=x86_64-apple-darwin --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net --unstable --no-check=remote --output ./build/hyper-x86_64-apple-darwin mod.js
@deno compile --target=x86_64-apple-darwin \
--allow-sys --allow-env --allow-read --allow-write=__hyper__ --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-apple-darwin-$(VER) mod.js

compile-arch-apple:
@deno compile --target=aarch64-apple-darwin --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net --unstable --no-check=remote --output ./build/hyper-aarch64-apple-darwin mod.js
@deno compile --target=aarch64-apple-darwin \
--allow-sys --allow-env --allow-read --allow-write=__hyper__ --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-aarch64-apple-darwin-$(VER) mod.js

compile-windows:
@deno compile --target=x86_64-pc-windows-msvc --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net --unstable --no-check=remote --output ./build/hyper-x86_64-pc-windows-msvc mod.js
@deno compile --target=x86_64-pc-windows-msvc \
--allow-sys --allow-env --allow-read --allow-write=__hyper__ --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-pc-windows-msvc-$(VER) mod.js
10 changes: 6 additions & 4 deletions images/nano/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ const { dirname, join } = require('path')
const chalk = require('chalk')
const ora = require('ora')

const { version } = require('../package.json')

const destDir = join(dirname('.'))
const binaryDest = join(destDir, 'hyper-nano')

function getBinary() {
const binaries = {
linux: 'hyper-x86_64-unknown-linux-gnu',
win32: 'hyper-x86_64-pc-windows-msvc.exe',
darwinx86_64: 'hyper-x86_64-apple-darwin',
darwinarm64: 'hyper-aarch64-apple-darwin',
linux: `hyper-x86_64-unknown-linux-gnu-${version}`,
win32: `hyper-x86_64-pc-windows-msvc-${version}.exe`,
darwinx86_64: `hyper-x86_64-apple-darwin-${version}`,
darwinarm64: `hyper-aarch64-apple-darwin-${version}`,
}

const os = platform()
Expand Down

0 comments on commit 805272b

Please sign in to comment.