-
Notifications
You must be signed in to change notification settings - Fork 25
129 lines (116 loc) · 4.72 KB
/
build-ampd-release.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: test
on:
push:
jobs:
release-binaries:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12]
arch: [amd64, arm64]
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ghwf-${{ github.event.repository.name }}
- name: Validate tag
env:
SEMVER: v1.1.1
run: |
if [[ $SEMVER =~ v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; then echo "Tag is okay" && exit 0; else echo "invalid tag" && exit 1; fi
aws s3 ls s3://axelar-releases/ampd/"$SEMVER" && echo "tag already exists, use a new one" && exit 1
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: '0'
submodules: recursive
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: build and sign darwin binaries
env:
SEMVER: v1.1.1
if: matrix.os == 'macos-12'
run: |
OS="darwin"
ARCH="${{ matrix.arch }}"
if [ "$ARCH" == "arm64" ]
then
brew install protobuf
rustup target add aarch64-apple-darwin
cargo build --release --target aarch64-apple-darwin
mkdir ampdbin
mv "/Users/runner/work/axelar-amplifier/axelar-amplifier/target/aarch64-apple-darwin/release/ampd" "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
gpg --armor --detach-sign "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
else
brew install protobuf
cargo build --release
mkdir ampdbin
mv "/Users/runner/work/axelar-amplifier/axelar-amplifier/target/release/ampd" "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
gpg --armor --detach-sign "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
fi
- name: build and sign linux binaries
env:
SEMVER: v1.1.1
if: matrix.os == 'ubuntu-22.04'
run: |
OS="linux"
ARCH="${{ matrix.arch }}"
if [ "$ARCH" == "arm64" ]
then
sudo apt-get install protobuf-compiler gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
cargo build --release --target aarch64-unknown-linux-gnu
mkdir ampdbin
mv "/home/runner/work/axelar-amplifier/axelar-amplifier/target/aarch64-unknown-linux-gnu/release/ampd" "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
gpg --armor --detach-sign "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
else
sudo apt-get install protobuf-compiler
cargo build --release
mkdir ampdbin
mv "/home/runner/work/axelar-amplifier/axelar-amplifier/target/release/ampd" "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
gpg --armor --detach-sign "./ampdbin/ampd-$OS-$ARCH-$SEMVER"
fi
- name: Test Binary Format
working-directory: ./ampdbin
run: |
for binary in ./ampd-*; do
if [[ "$binary" != *.asc ]]; then
echo "Testing binary: $binary"
if [[ "${{ matrix.os }}" == "ubuntu-22.04" ]]; then
OUTPUT=$(file "$binary" | awk -F, '{print $1"," $2}')
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
EXPECTED="ELF 64-bit LSB pie executable, x86-64"
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
EXPECTED="ELF 64-bit LSB pie executable, ARM aarch64"
fi
elif [[ "${{ matrix.os }}" == "macos-12" ]]; then
OUTPUT=$(file "$binary")
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
EXPECTED="Mach-O 64-bit executable x86_64"
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
EXPECTED="Mach-O 64-bit executable arm64"
fi
fi
echo "Output: $OUTPUT"
echo "Expected: $EXPECTED"
if [[ "$OUTPUT" == *"$EXPECTED"* ]]; then
echo "The binary format is correct."
else
echo "Error: The binary format does not match the expected format."
exit 1
fi
fi
done