Skip to content

Commit 91d2c2d

Browse files
committed
spike
0 parents  commit 91d2c2d

20 files changed

+2609
-0
lines changed

.github/workflows/build.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build_x64:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: 18
14+
- run: npm i -g yarn
15+
- run: yarn
16+
- run: yarn build
17+
- uses: actions/upload-artifact@v3
18+
with:
19+
name: bls-linux-x64-blockless-cli
20+
path: bls_x64-linux*
21+
- uses: actions/upload-artifact@v3
22+
with:
23+
name: bls-windows-x64-blockless-cli
24+
path: bls_x64-win*
25+
- uses: actions/upload-artifact@v3
26+
with:
27+
name: bls-macos-x64-blockless-cli
28+
path: bls_x64-macos*
29+
build_arm:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: 18
36+
- run: npm i -g yarn
37+
- run: yarn
38+
- run: yarn build:arm
39+
- uses: actions/upload-artifact@v3
40+
with:
41+
name: bls-linux-arm64-blockless-cli
42+
path: bls_arm64-linux*
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
name: bls-windows-arm64-blockless-cli
46+
path: bls_arm64-win*
47+
- uses: actions/upload-artifact@v3
48+
with:
49+
name: bls-macos-arm64-blockless-cli
50+
path: bls_arm64-macos*

.github/workflows/release.yml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
on:
2+
release:
3+
types: [created]
4+
5+
name: Release
6+
7+
jobs:
8+
build_and_test:
9+
if: contains(github.ref,'latest') == false
10+
runs-on: self-hosted
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 18
16+
- run: npm i -g yarn
17+
- run: yarn
18+
- run: yarn build
19+
- run: yarn build:arm
20+
- name: Archive Release
21+
uses: thedoctor0/zip-release@main
22+
with:
23+
type: "tar"
24+
filename: bls-linux-x64-blockless-cli.tar.gz
25+
path: bls_x64-linux*
26+
- name: Archive Release
27+
uses: thedoctor0/zip-release@main
28+
with:
29+
type: "tar"
30+
filename: bls-windows-x64-blockless-cli.tar.gz
31+
path: bls_x64-win*
32+
- name: Archive Release
33+
uses: thedoctor0/zip-release@main
34+
with:
35+
type: "tar"
36+
filename: bls-macos-x64-blockless-cli.tar.gz
37+
path: bls_x64-macos*
38+
39+
- name: Archive Release
40+
uses: thedoctor0/zip-release@main
41+
with:
42+
type: "tar"
43+
filename: bls-linux-arm64-blockless-cli.tar.gz
44+
path: bls_arm64-linux*
45+
- name: Archive Release
46+
uses: thedoctor0/zip-release@main
47+
with:
48+
type: "tar"
49+
filename: bls-windows-arm64-blockless-cli.tar.gz
50+
path: bls_arm64-win*
51+
- name: Archive Release
52+
uses: thedoctor0/zip-release@main
53+
with:
54+
type: "tar"
55+
filename: bls-macos-arm64-blockless-cli.tar.gz
56+
path: bls_arm64-macos*
57+
- name: Get release
58+
id: get_release
59+
uses: bruceadams/[email protected]
60+
env:
61+
GITHUB_TOKEN: ${{ github.token }}
62+
- name: upload artifact
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ github.token }}
66+
with:
67+
upload_url: ${{ steps.get_release.outputs.upload_url }}
68+
asset_path: bls-macos-arm64-blockless-cli.tar.gz
69+
asset_name: bls-macos-arm64-blockless-cli.tar.gz
70+
asset_content_type: application/gzip
71+
72+
- name: upload artifact
73+
uses: actions/upload-release-asset@v1
74+
env:
75+
GITHUB_TOKEN: ${{ github.token }}
76+
with:
77+
upload_url: ${{ steps.get_release.outputs.upload_url }}
78+
asset_path: bls-linux-arm64-blockless-cli.tar.gz
79+
asset_name: bls-linux-arm64-blockless-cli.tar.gz
80+
asset_content_type: application/gzip
81+
82+
- name: upload artifact
83+
uses: actions/upload-release-asset@v1
84+
env:
85+
GITHUB_TOKEN: ${{ github.token }}
86+
with:
87+
upload_url: ${{ steps.get_release.outputs.upload_url }}
88+
asset_path: bls-windows-arm64-blockless-cli.tar.gz
89+
asset_name: bls-windows-arm64-blockless-cli.tar.gz
90+
asset_content_type: application/gzip
91+
92+
- name: upload artifact
93+
uses: actions/upload-release-asset@v1
94+
env:
95+
GITHUB_TOKEN: ${{ github.token }}
96+
with:
97+
upload_url: ${{ steps.get_release.outputs.upload_url }}
98+
asset_path: bls-macos-x64-blockless-cli.tar.gz
99+
asset_name: bls-macos-x64-blockless-cli.tar.gz
100+
asset_content_type: application/gzip
101+
102+
- name: upload artifact
103+
uses: actions/upload-release-asset@v1
104+
env:
105+
GITHUB_TOKEN: ${{ github.token }}
106+
with:
107+
upload_url: ${{ steps.get_release.outputs.upload_url }}
108+
asset_path: bls-linux-x64-blockless-cli.tar.gz
109+
asset_name: bls-linux-x64-blockless-cli.tar.gz
110+
asset_content_type: application/gzip
111+
112+
- name: upload artifact
113+
uses: actions/upload-release-asset@v1
114+
env:
115+
GITHUB_TOKEN: ${{ github.token }}
116+
with:
117+
upload_url: ${{ steps.get_release.outputs.upload_url }}
118+
asset_path: bls-windows-x64-blockless-cli.tar.gz
119+
asset_name: bls-windows-x64-blockless-cli.tar.gz
120+
asset_content_type: application/gzip
121+
122+
# - uses: actions/upload-artifact@v3
123+
# with:
124+
# path: blockless-cli.${{ matrix.os }}.x64.tar.gz
125+
# retention-days: 1
126+
127+
# update_latest:
128+
# needs: build_and_test
129+
# runs-on: ubuntu-latest
130+
# steps:
131+
# - uses: actions/download-artifact@v3
132+
# with:
133+
# path: .
134+
# - name: Delete the "latest" Release
135+
# uses: dev-drprasad/[email protected]
136+
# with:
137+
# tag_name: latest
138+
# delete_release: true
139+
# env:
140+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
# - name: Publish the Release
142+
# uses: softprops/action-gh-release@v1
143+
# with:
144+
# tag_name: latest
145+
# files: artifact/*
146+
# prerelease: true
147+
# fail_on_unmatched_files: true
148+
# env:
149+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.temp/
2+
dist/
3+
node_modules/

README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# `bls` the blockless cli
2+
3+
Command your blockless deployments and projects, and participate in our on-chain network.
4+
5+
If you intend to run a blockchain Validator, Node, IBC Relayer, or would rather interact with only the on-chain network see [`blsd` blockless chain](https://github.com/txlabs/blockless-chain/)
6+
7+
## installing
8+
9+
Install the latest version of the prebuilt CLI by running the following command on bash.
10+
11+
Supported Platforms
12+
13+
| OS | arm64 | x64 |
14+
| ------- | ----- | --- |
15+
| Windows | x | x |
16+
| Linux | x | x |
17+
| MacOS | x | x |
18+
19+
curl
20+
21+
```bash
22+
sudo sh -c "curl https://raw.githubusercontent.com/txlabs/blockless-cli/main/download.sh | bash"
23+
```
24+
25+
wget
26+
27+
```bash
28+
sudo sh -c "wget https://raw.githubusercontent.com/txlabs/blockless-cli/main/download.sh -v -O download.sh; chmod +x download.sh; ./download.sh; rm -rf download.sh"
29+
```
30+
31+
In a different environment? Use `npm` with `node 14`.
32+
33+
```bash
34+
npm i -g @blockless/cli
35+
```
36+
37+
## contributing
38+
39+
this client command utility is written in `typescript` , and packaged using `nexe`.
40+
41+
- Node 14.15
42+
- Typescript
43+
- Pkg Wrapper
44+
45+
use `dev-bin.js` to test locally, use `npm link` if you wish to test bin globally installed.

bin.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { cli } = require("./dist/src/index");
2+
cli(process.argv);

dev-bin.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
require("ts-node/register");
3+
const { cli } = require("./src/index");
4+
cli(process.argv);

download.sh

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/bash
2+
TMP_DIR="/tmp/tmpinstalldir"
3+
function cleanup {
4+
echo rm -rf $TMP_DIR > /dev/null
5+
}
6+
function fail {
7+
cleanup
8+
msg=$1
9+
echo "============"
10+
echo "Error: $msg" 1>&2
11+
exit 1
12+
}
13+
function install {
14+
#settings
15+
USER="txlabs"
16+
PROG='bls'
17+
MOVE="true"
18+
RELEASE="latest"
19+
INSECURE="false"
20+
OUT_DIR="/usr/local/bin"
21+
GH="https://github.com"
22+
#bash check
23+
[ ! "$BASH_VERSION" ] && fail "Please use bash instead"
24+
[ ! -d $OUT_DIR ] && fail "output directory missing: $OUT_DIR"
25+
#dependency check, assume we are a standard POISX machine
26+
which find > /dev/null || fail "find not installed"
27+
which xargs > /dev/null || fail "xargs not installed"
28+
which sort > /dev/null || fail "sort not installed"
29+
which tail > /dev/null || fail "tail not installed"
30+
which cut > /dev/null || fail "cut not installed"
31+
which du > /dev/null || fail "du not installed"
32+
GET=""
33+
if which curl > /dev/null; then
34+
GET="curl"
35+
if [[ $INSECURE = "true" ]]; then GET="$GET --insecure"; fi
36+
GET="$GET --fail -# -L"
37+
elif which wget > /dev/null; then
38+
GET="wget"
39+
if [[ $INSECURE = "true" ]]; then GET="$GET --no-check-certificate"; fi
40+
GET="$GET -qO-"
41+
else
42+
fail "neither wget/curl are installed"
43+
fi
44+
#find OS #TODO BSDs and other posixs
45+
case `uname -s` in
46+
Darwin) OS="darwin";;
47+
Linux) OS="linux";;
48+
*) fail "unknown os: $(uname -s)";;
49+
esac
50+
#find ARCH
51+
if uname -m | grep 64 | grep arm > /dev/null; then
52+
ARCH="arm64"
53+
elif uname -m | grep 64 | grep aarch > /dev/null; then
54+
ARCH="arm64"
55+
elif uname -m | grep 64 > /dev/null; then
56+
ARCH="amd64"
57+
elif uname -m | grep arm > /dev/null; then
58+
ARCH="arm" #TODO armv6/v7
59+
elif uname -m | grep 386 > /dev/null; then
60+
ARCH="386"
61+
else
62+
fail "unknown arch: $(uname -m)"
63+
fi
64+
65+
#choose from asset list
66+
URL=""
67+
FTYPE=""
68+
VERSION="0.0.1"
69+
case "${OS}_${ARCH}" in
70+
"darwin_amd64")
71+
URL="https://github.com/txlabs/blockless-cli/releases/download/${VERSION}/bls-macos-x64-blockless-cli.tar.gz"
72+
FTYPE=".tar.gz"
73+
;;
74+
"darwin_arm64")
75+
URL="https://github.com/txlabs/blockless-cli/releases/download/${VERSION}/bls-macos-arm64-blockless-cli.tar.gz"
76+
FTYPE=".tar.gz"
77+
;;
78+
"linux_amd64")
79+
URL="https://github.com/txlabs/blockless-cli/releases/download/${VERSION}/bls-linux-arm64-blockless-cli.tar.gz"
80+
FTYPE=".tar.gz"
81+
;;
82+
"linux_arm64")
83+
URL="https://github.com/txlabs/blockless-cli/releases/download/${VERSION}/bls-linux-arm64-blockless-cli.tar.gz"
84+
FTYPE=".tar.gz"
85+
;;
86+
*) fail "No asset for platform ${OS}-${ARCH}";;
87+
esac
88+
#got URL! download it...
89+
echo -n "Installing $PROG $RELEASE"
90+
91+
echo "....."
92+
93+
#enter tempdir
94+
mkdir -p $TMP_DIR
95+
cd $TMP_DIR
96+
if [[ $FTYPE = ".gz" ]]; then
97+
which gzip > /dev/null || fail "gzip is not installed"
98+
#gzipped binary
99+
NAME="${PROG}_${OS}_${ARCH}.gz"
100+
GZURL="$GH/releases/download/$RELEASE/$NAME"
101+
#gz download!
102+
bash -c "$GET $URL" | gzip -d - > $PROG || fail "download failed"
103+
elif [[ $FTYPE = ".tar.gz" ]] || [[ $FTYPE = ".tgz" ]]; then
104+
#check if archiver progs installed
105+
which tar > /dev/null || fail "tar is not installed"
106+
which gzip > /dev/null || fail "gzip is not installed"
107+
bash -c "$GET $URL" | tar zxf - || fail "download failed"
108+
elif [[ $FTYPE = ".zip" ]]; then
109+
which unzip > /dev/null || fail "unzip is not installed"
110+
bash -c "$GET $URL" > tmp.zip || fail "download failed"
111+
unzip -o -qq tmp.zip || fail "unzip failed"
112+
rm tmp.zip || fail "cleanup failed"
113+
elif [[ $FTYPE = "" ]]; then
114+
bash -c "$GET $URL" > "blockless-chain_${OS}_${ARCH}" || fail "download failed"
115+
else
116+
fail "unknown file type: $FTYPE"
117+
fi
118+
#search subtree largest file (bin)
119+
TMP_BIN=$(find . -type f | xargs du | sort -n | tail -n 1 | cut -f 2)
120+
if [ ! -f "$TMP_BIN" ]; then
121+
fail "could not find find binary (largest file)"
122+
fi
123+
#ensure its larger than 1MB
124+
if [[ $(du -m $TMP_BIN | cut -f1) -lt 1 ]]; then
125+
fail "no binary found ($TMP_BIN is not larger than 1MB)"
126+
fi
127+
#move into PATH or cwd
128+
chmod +x $TMP_BIN || fail "chmod +x failed"
129+
130+
mv $TMP_BIN $OUT_DIR/$PROG || fail "mv failed" #FINAL STEP!
131+
echo "Installed at $OUT_DIR/$PROG"
132+
#done
133+
cleanup
134+
}
135+
install

0 commit comments

Comments
 (0)