Skip to content
This repository was archived by the owner on Sep 4, 2022. It is now read-only.

Commit a054b87

Browse files
committed
Add CLI binary
1 parent 3bc3406 commit a054b87

File tree

10 files changed

+131
-1094
lines changed

10 files changed

+131
-1094
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ft = "test --features fast-test"
33
lt = "test"
44
cov = "tarpaulin --ignore-tests --out Lcov --features fast-test"
55
ir = "insta review"
6+
r = "run --features build-binary --bin ipld-schema"
67
w = "watch -c -x ir -x ft -x clippy -x doc"

.github/workflows/cd.yml

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,101 @@ on:
66
- '[0-9]+.[0-9]+.[0-9]+'
77

88
jobs:
9+
publish:
10+
name: Publishing for ${{ matrix.job.os }}
11+
runs-on: ${{ matrix.job.os }}
12+
strategy:
13+
matrix:
14+
rust: [stable]
15+
job:
16+
- os: macos-latest
17+
os-name: macos
18+
target: x86_64-apple-darwin
19+
architecture: x86_64
20+
binary-postfix: ""
21+
use-cross: false
22+
- os: ubuntu-20.04
23+
os-name: linux
24+
target: x86_64-unknown-linux-gnu
25+
architecture: x86_64
26+
binary-postfix: ""
27+
use-cross: false
28+
- os: windows-latest
29+
os-name: windows
30+
target: x86_64-pc-windows-msvc
31+
architecture: x86_64
32+
binary-postfix: ".exe"
33+
use-cross: false
34+
- os: ubuntu-20.04
35+
os-name: linux
36+
target: aarch64-unknown-linux-gnu
37+
architecture: arm64
38+
binary-postfix: ""
39+
use-cross: true
40+
- os: ubuntu-20.04
41+
os-name: linux
42+
target: i686-unknown-linux-gnu
43+
architecture: i686
44+
binary-postfix: ""
45+
use-cross: true
46+
steps:
47+
- name: Installing Rust toolchain
48+
uses: actions-rs/toolchain@v1
49+
with:
50+
toolchain: ${{ matrix.rust }}
51+
profile: minimal
52+
override: true
53+
- name: Checkout repository
54+
uses: actions/checkout@v2
55+
- name: Cargo build
56+
uses: actions-rs/cargo@v1
57+
with:
58+
command: build
59+
use-cross: ${{ matrix.job.use-cross }}
60+
toolchain: ${{ matrix.rust }}
61+
args: --release --target ${{ matrix.job.target }} --features build-binary
62+
63+
- name: install strip command
64+
shell: bash
65+
run: |
66+
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
67+
sudo apt update
68+
sudo apt-get install -y binutils-aarch64-linux-gnu
69+
fi
70+
- name: Packaging final binary
71+
shell: bash
72+
run: |
73+
cd target/${{ matrix.job.target }}/release
74+
####### reduce binary size by removing debug symbols #######
75+
BINARY_NAME=ipld-schema${{ matrix.job.binary-postfix }}
76+
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
77+
GCC_PREFIX="aarch64-linux-gnu-"
78+
else
79+
GCC_PREFIX=""
80+
fi
81+
"$GCC_PREFIX"strip $BINARY_NAME
82+
########## create tar.gz ##########
83+
RELEASE_NAME=ipld-schema-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
84+
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
85+
########## create sha256 ##########
86+
if [[ ${{ runner.os }} == 'Windows' ]]; then
87+
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
88+
else
89+
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
90+
fi
91+
- name: Releasing assets
92+
uses: softprops/action-gh-release@v1
93+
with:
94+
files: |
95+
target/${{ matrix.job.target }}/release/ipld-schema-*.tar.gz
96+
target/${{ matrix.job.target }}/release/ipld-schema-*.sha256
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
9101
publish-cargo:
10102
name: Publishing to Cargo
11-
runs-on: ubuntu-latest
103+
runs-on: ubuntu-20.04
12104
steps:
13105
- uses: actions/checkout@master
14106
- uses: actions-rs/toolchain@v1

.github/workflows/ci.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77

88
test:
99
name: Test Suite
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-20.04
1111
strategy:
1212
matrix:
1313
rust:
@@ -28,9 +28,28 @@ jobs:
2828
with:
2929
command: test
3030

31+
build-binary:
32+
name: Build binary
33+
runs-on: ubuntu-20.04
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v2
37+
- name: Checkout submodules
38+
run: git submodule update --init --recursive
39+
- name: Install Rust
40+
uses: actions-rs/toolchain@v1
41+
with:
42+
toolchain: stable
43+
profile: minimal
44+
override: true
45+
- uses: actions-rs/cargo@v1
46+
with:
47+
command: r
48+
args: -- --help
49+
3150
rustfmt:
3251
name: Rustfmt
33-
runs-on: ubuntu-latest
52+
runs-on: ubuntu-20.04
3453
steps:
3554
- name: Checkout repository
3655
uses: actions/checkout@v2
@@ -49,7 +68,7 @@ jobs:
4968

5069
clippy:
5170
name: Clippy
52-
runs-on: ubuntu-latest
71+
runs-on: ubuntu-20.04
5372
steps:
5473
- name: Checkout repository
5574
uses: actions/checkout@v2
@@ -67,7 +86,7 @@ jobs:
6786

6887
coverage:
6988
name: Code coverage
70-
runs-on: ubuntu-latest
89+
runs-on: ubuntu-20.04
7190
steps:
7291
- name: Checkout repository
7392
uses: actions/checkout@v2

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
.cargo-ok
33
Cargo.lock
44
*~
5+
6+
# cargo-tarpaulin outputs
7+
lcov.info
8+
tarpaulin-report.*
9+
cobertura.xml

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ license = "MIT OR Apache-2.0"
99

1010
[features]
1111
fast-test = []
12+
build-binary = []
13+
14+
[[bin]]
15+
name = "ipld-schema"
16+
path = "./src/cli.rs"
17+
required-features = ["build-binary"]
1218

1319
[dependencies]
1420
peg = "0.6.3"

cobertura.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)