-
Notifications
You must be signed in to change notification settings - Fork 44
71 lines (71 loc) · 3.07 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CD
on:
push:
tags:
- "[v]?[0-9]+.[0-9]+.[0-9]+"
jobs:
publish:
name: Publishing for ${{ matrix.job.os }}
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
rust: [nightly]
job:
- os: ubuntu-latest
os-name: linux
target: x86_64-unknown-linux-gnu
architecture: x86_64
binary-postfix: ""
use-cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Setup build env
run: |
ROOT_DIR=`pwd`
sudo apt-get install protobuf-compiler
cargo install cargo-edit
cd ${ROOT_DIR}/metadata && yarn install && npx hardhat compile
test -e ${ROOT_DIR}/metadata/artifacts/contracts/DB3MetaStore.sol/DB3MetaStore.json && cp -f ${ROOT_DIR}/metadata/artifacts/contracts/DB3MetaStore.sol/DB3MetaStore.json ${ROOT_DIR}/abi/
test -e ${ROOT_DIR}/metadata/artifacts/contracts/libraries/Events.sol/Events.json && cp -f ${ROOT_DIR}/metadata/artifacts/contracts/libraries/Events.sol/Events.json ${ROOT_DIR}/abi/
cd ${ROOT_DIR}
TAG=${GITHUB_REF/refs\/tags\//}
VERSION=${TAG#*v}
echo ${VERSION}
cargo set-version --workspace ${VERSION}
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.job.use-cross }}
toolchain: ${{ matrix.rust }}
args: --release --target ${{ matrix.job.target }}
- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.job.target }}/release
TAG=${GITHUB_REF/refs\/tags\//}
VERSION=${TAG#*v}
RELEASE_NAME=db3-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
mkdir -p $RELEASE_NAME/bin
DB3_BINARY_NAME=db3
mv $DB3_BINARY_NAME $TM_BINARY_NAME $RELEASE_NAME/bin/
tar czvf $RELEASE_NAME.tar.gz $RELEASE_NAME
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.job.target }}/release/db3*.tar.gz
target/${{ matrix.job.target }}/release/db3*.sha256
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}