-
Notifications
You must be signed in to change notification settings - Fork 126
219 lines (195 loc) · 8.65 KB
/
packaging.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Package linux binaries
env:
VERSIONS_LIST: "0.10.7,0.13.6,0.14.1,0.17.3,0.18.3,0.19.4,0.21.1,0.24.0,0.26.5,0.28.0,0.29.1,0.31.2,0.31.3,0.32.0,0.32.2,0.33.0"
on:
workflow_dispatch:
jobs:
package-binaries:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
arch: [amd64]
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Configure AWS credentials
run: |
cd $HOME; mkdir ~/.aws; touch ~/.aws/credentials; touch ~/.aws/config
echo "[default]
aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID_CF }}
aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }}" > ~/.aws/credentials
echo "[default]
region=auto
output=json" > ~/.aws/config
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: '0'
submodules: recursive
- name: Install prerequisites
run: |
sudo apt-get install -y gcc dpkg-dev gpg
- name: Create folder structures for Linux
run: |
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
mkdir -p ~/linux/axelard_$version-1_$arch/usr/bin/
mkdir -p ~/linux/axelard_$version-1_$arch/DEBIAN/
done
done
- name: Get binaries
run: |
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
filename="axelard_$version-1_$arch.deb"
if ! output=$(aws s3 ls "s3://axelar-static/axelard/apt-repo/pool/main/$filename" --endpoint-url ${{ secrets.S3_BIN }} 2>&1); then
echo "Downloading $filename..."
wget -O ~/linux/axelard_$version-1_$arch/usr/bin/axelard --no-check-certificate https://github.com/axelarnetwork/axelar-core/releases/download/v$version/axelard-linux-$arch-v$version
chmod 755 ~/linux/axelard_$version-1_$arch/usr/bin/axelard
else
echo "Package file already exists in S3: $filename"
fi
done
done
- name: Create control files
run: |
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
echo "Package: axelard
Version: $version
Maintainer: axelar <[email protected]>
Architecture: $arch
Homepage: https://axelar.network
Description: axelard binary for Linux $arch" \
> ~/linux/axelard_$version-1_$arch/DEBIAN/control
done
done
- name: Build the packages if they don't exist on S3
run: |
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
filename="axelard_$version-1_$arch.deb"
if ! output=$(aws s3 ls "s3://axelar-static/axelard/apt-repo/pool/main/$filename" --endpoint-url ${{ secrets.S3_BIN }} 2>&1); then
echo "Package not present in S3: $output"
dpkg --build ~/linux/axelard_$version-1_$arch
else
echo "Package file already exists in S3: $filename"
fi
done
done
- name: Check the packages
run: |
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
file="/home/runner/linux/axelard_$version-1_$arch.deb"
if [ -f $file ]; then
dpkg-deb --info $file
dpkg-deb --contents $file
fi
done
done
- name: Copy binaries in apt repo
run: |
mkdir -p ~/axelard/apt-repo/pool/main/
if ls /home/runner/linux/*.deb; then
cp /home/runner/linux/*.deb ~/axelard/apt-repo/pool/main/.
fi
ls -l ~/axelard/apt-repo/pool/main/
- name: Generate Packages files
run: |
cd ~/axelard/apt-repo
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in amd64 arm64 arm; do
mkdir -p dists/stable/main/binary-$arch
if [ -f ~/axelard/apt-repo/pool/main/axelard_${version}-1_$arch.deb ]; then
dpkg-scanpackages -m --arch $arch pool/ > dists/stable/main/binary-$arch/Packages
gzip -9 < dists/stable/main/binary-$arch/Packages > dists/stable/main/binary-$arch/Packages.gz
cat dists/stable/main/binary-$arch/Packages
else
echo "Package file not found: ~/axelard/apt-repo/pool/main/axelard_${version}-1_$arch.deb"
fi
done
done
- name: Generate Release file
run: |
echo '#!/bin/sh
set -e
do_hash() {
HASH_NAME=$1
HASH_CMD=$2
echo "${HASH_NAME}:"
for f in $(find -type f); do
f=$(echo $f | cut -c3-) # remove ./ prefix
if [ "$f" = "Release" ]; then
continue
fi
echo " $(${HASH_CMD} ${f} | cut -d" " -f1) $(wc -c $f)"
done
}
cat << EOF
Origin: Axelard repository
Label: axelard
Suite: stable
Codename: stable
Version: VERSION
Architectures: amd64 arm64 arm
Components: main
Description: Axelard repository
Date: $(date -Ru)
EOF
do_hash "MD5Sum" "md5sum"
do_hash "SHA1" "sha1sum"
do_hash "SHA256" "sha256sum"' > ~/axelard/generate-release.sh && chmod +x ~/axelard/generate-release.sh
sed -i "s/VERSION/$version/g" ~/axelard/generate-release.sh
cd ~/axelard/apt-repo/dists/stable
~/axelard/generate-release.sh > Release
cat ~/axelard/apt-repo/dists/stable/Release
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: GPG sign apt repo
run: |
cat ~/axelard/apt-repo/dists/stable/Release | gpg --default-key 5D9FFADEED11FA5D -abs > ~/axelard/apt-repo/dists/stable/Release.gpg
- name: Upload to S3
run: |
cd ~/
architectures=("amd64" "arm64" "arm")
for arch in "${architectures[@]}"; do
aws s3api put-object --endpoint-url ${{ secrets.S3_BIN }} --bucket axelar-static --key "axelard/apt-repo/dists/stable/main/binary-$arch/Packages.gz" --body "axelard/apt-repo/dists/stable/main/binary-$arch/Packages.gz"
aws s3api put-object --endpoint-url ${{ secrets.S3_BIN }} --bucket axelar-static --key "axelard/apt-repo/dists/stable/main/binary-$arch/Packages" --body "axelard/apt-repo/dists/stable/main/binary-$arch/Packages"
done
aws s3api put-object --endpoint-url ${{ secrets.S3_BIN }} --bucket axelar-static --key "axelard/apt-repo/dists/stable/Release" --body "axelard/apt-repo/dists/stable/Release"
aws s3api put-object --endpoint-url ${{ secrets.S3_BIN }} --bucket axelar-static --key "axelard/apt-repo/dists/stable/Release.gpg" --body "axelard/apt-repo/dists/stable/Release.gpg"
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
for arch in "${architectures[@]}"; do
key="axelard/apt-repo/pool/main/axelard_$version-1_$arch.deb"
if ! aws s3api head-object --bucket axelar-static --key "$key" --endpoint-url ${{ secrets.S3_BIN }} > /dev/null 2>&1; then
aws s3api put-object --endpoint-url ${{ secrets.S3_BIN }} --bucket axelar-static --key "$key" --body "axelard/apt-repo/pool/main/axelard_$version-1_$arch.deb"
fi
done
done
- name: Get GPG public key
run: |
curl https://keybase.io/axelardev/pgp_keys.asc | gpg --import
curl https://keybase.io/axelardev/pgp_keys.asc | sudo apt-key add -
- name: Install axelard and test
run: |
echo "deb [arch=amd64] http://static.axelar.network/axelard/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/axelar.list
sudo apt-get clean
sudo apt-get update
sudo apt list --all-versions axelard
for version in $(echo $VERSIONS_LIST | tr "," "\n"); do
if sudo apt-get install -y axelard=$version; then
axelard version
which axelard
sudo apt-get remove -y axelard=$version
else
echo "Package not found: axelard=$version"
fi
done