Skip to content

Commit ba8622c

Browse files
authored
adds an action for release automatization (#1210)
* adds an action for release automatization After trying different ready-to-use actions, I think I found the best one (so far). The good things about this action are: 1) It allows us to upload many files using file patterns. 2) Generates changelog automatically. 3) Rewrites releases with the same tag, so there is no need somehow to query `github` and to delete the previous release. The proposal workflow is to run this action once a week. When `bap` will be ready for the next release, just rename the current tag from `v2.2.0-alpha` to `v2.2.0` and drop the `prerelease` checkbox. * resolves codasy issues * uses ubuntu-18.04 instead of ubuntu-latest
1 parent 7cc4c6c commit ba8622c

File tree

2 files changed

+248
-0
lines changed

2 files changed

+248
-0
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: release
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * SAT' # every Saturday
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-18.04
10+
11+
env:
12+
OPAMJOBS: 2
13+
OPAMRETRES: 8
14+
VERSION: 2.2.0
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Install OCaml
21+
uses: avsm/setup-ocaml@v1
22+
with:
23+
ocaml-version: 4.09.1+flambda
24+
25+
- name: Build deb packages
26+
run: ./tools/release.sh ${{ env.VERSION }}
27+
28+
# caution: this action overwrite the tag and deletes
29+
# releases that are associated with it
30+
- name: Create a new prerelease
31+
uses: "marvinpinto/action-automatic-releases@latest"
32+
with:
33+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
34+
automatic_release_tag: v${{ env.VERSION }}-alpha
35+
prerelease: true
36+
title: "Development Build"
37+
files: bap/*

tools/release.sh

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
sudo apt-get update
6+
sudo apt-get install alien autoconf --yes
7+
8+
BAP_VERSION=$1
9+
echo "version is $BAP_VERSION"
10+
11+
12+
GITHUB=https://github.com/BinaryAnalysisPlatform/
13+
SOURCE=$GITHUB/bap
14+
BINDINGS=$GITHUB/bap-bindings
15+
BINARIES="bap bapbundle bapbuild bap-mc"
16+
PREFIX=/usr/local
17+
ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
18+
CONFDIR=$PREFIX/etc/bap
19+
TMPDIR=$(mktemp -d)
20+
21+
eval $(opam config env)
22+
echo OCaml is at $(which ocaml)
23+
echo "Looking in the dev-repo for the current list of dependencies"
24+
opam pin add bap --dev-repo --yes -n
25+
echo "Installing System dependenices"
26+
opam depext bap --yes
27+
echo "Installing OCaml dependenices"
28+
opam install --yes --deps-only bap
29+
echo "Installed dependencies. Cleaning up..."
30+
opam pin remove bap
31+
32+
echo "Cloning a fresh repo"
33+
[ -d bap-repo ] || git clone $SOURCE bap-repo
34+
echo "Installing ocamlfind to the system path"
35+
36+
[ -f $PREFIX/bin/ocamlfind ] && cp $PREFIX/bin/ocamlfind $TMPDIR/stored-ocamlfind
37+
sudo cp $(which ocamlfind) $PREFIX/bin
38+
39+
40+
cd bap-repo
41+
LLVM_VERSION=$(opam config var conf-bap-llvm:package-version)
42+
LLVM_CONFIG=$(opam config var conf-bap-llvm:config)
43+
44+
SIGURL=https://github.com/BinaryAnalysisPlatform/bap/releases/download/v2.1.0
45+
echo BAP version is $BAP_VERSION
46+
echo LLVM is $LLVM_VERSION
47+
48+
sed -i "s/-j 2/-j 4/" oasis/common
49+
50+
./configure --enable-everything \
51+
--disable-ida \
52+
--with-llvm-version=$LLVM_VERSION \
53+
--with-llvm-config=$LLVM_CONFIG \
54+
--libdir=$PREFIX/lib/bap \
55+
--plugindir=$PREFIX/lib/bap \
56+
--prefix=$PREFIX \
57+
--sysconfdir=$CONFDIR
58+
59+
make
60+
sudo sh -c "PATH=$PATH make reinstall"
61+
cd ..
62+
63+
echo "Packing a bap debian package"
64+
65+
sudo rm -rf bap
66+
67+
mkdir -p bap/bap_$BAP_VERSION/DEBIAN
68+
69+
SHARED=bap/bap_$BAP_VERSION/$PREFIX/share
70+
BINDIR=bap/bap_$BAP_VERSION/$PREFIX/bin
71+
LIBDIR=bap/bap_$BAP_VERSION/$PREFIX/lib/bap
72+
SIGDIR=bap/bap_$BAP_VERSION/$PREFIX/share/bap
73+
DEBIAN=bap/bap_$BAP_VERSION/DEBIAN
74+
PRIMUS=$SHARED/primus/site-lisp
75+
BAPAPI=$SHARED/bap-api
76+
77+
mkdir -p $BINDIR $LIBDIR $SIGDIR $DEBIAN $PRIMUS $BAPAPI
78+
79+
for binary in $BINARIES; do
80+
cp $PREFIX/bin/$binary bap/bap_$BAP_VERSION/$PREFIX/bin
81+
done;
82+
83+
cp $PREFIX/lib/bap/*.plugin $LIBDIR
84+
curl -L $SIGURL/sigs.zip > $SIGDIR/sigs.zip
85+
86+
87+
LISPSRC="primus_lisp primus_taint primus_test constant_tracker primus_symbolic_executor"
88+
for src in $LISPSRC; do
89+
cp bap-repo/plugins/$src/lisp/*.lisp $PRIMUS/
90+
done;
91+
92+
cp -r bap-repo/plugins/api/api/c $BAPAPI
93+
cp bap-repo/plugins/primus_systems/systems/*.asd $SHARED/primus
94+
95+
96+
cat > $DEBIAN/control <<EOF
97+
Package: bap
98+
Architecture: $ARCH
99+
Maintainer: Ivan Gotovchits
100+
Depends: libgmp10, zlib1g, libstdc++6, libtinfo5
101+
Priority: optional
102+
Version: $BAP_VERSION
103+
Description: Binary Analysis Platform
104+
EOF
105+
106+
sudo chown -R root:root bap/bap_$BAP_VERSION
107+
dpkg-deb --build bap/bap_$BAP_VERSION
108+
109+
echo "now building the bindings"
110+
111+
opam install ctypes ctypes-foreign --yes
112+
113+
[ -d bap-bindings ] || git clone $BINDINGS bap-bindings
114+
115+
116+
cd bap-bindings
117+
git pull
118+
autoconf
119+
./configure
120+
make
121+
cd ..
122+
123+
124+
echo "Now packing libbap.deb"
125+
LIBDIR=bap/libbap_$BAP_VERSION/$PREFIX/lib
126+
DEBIAN=bap/libbap_$BAP_VERSION/DEBIAN
127+
128+
mkdir -p $LIBDIR $DEBIAN
129+
130+
131+
cp bap-bindings/_build/bap/libbap.so $LIBDIR/libbap.so.$BAP_VERSION
132+
133+
134+
cat > $DEBIAN/control <<EOF
135+
Package: libbap
136+
Architecture: $ARCH
137+
Maintainer: Ivan Gotovchits
138+
Depends: libgmp10, zlib1g, libstdc++6, libffi6, libtinfo5
139+
Priority: optional
140+
Version: $BAP_VERSION
141+
Description: Binary Analysis Platform C Library
142+
EOF
143+
144+
cat > $DEBIAN/postinst <<EOF
145+
#!/bin/sh
146+
sudo ldconfig
147+
EOF
148+
149+
cat > $DEBIAN/postrm <<EOF
150+
#!/bin/sh
151+
sudo ldconfig
152+
EOF
153+
154+
chmod a+x $DEBIAN/postinst
155+
chmod a+x $DEBIAN/postrm
156+
sudo chown -R root:root bap/libbap_$BAP_VERSION
157+
dpkg-deb --build bap/libbap_$BAP_VERSION
158+
159+
echo "Now packing libbap-dev"
160+
HDRDIR=bap/libbap-dev_$BAP_VERSION/$PREFIX/include
161+
DEBIAN=bap/libbap-dev_$BAP_VERSION/DEBIAN
162+
163+
mkdir -p $DEBIAN $HDRDIR
164+
cp bap-bindings/_build/bap/generated/bap.h $HDRDIR
165+
166+
cat > $DEBIAN/control <<EOF
167+
Package: libbap-dev
168+
Architecture: $ARCH
169+
Maintainer: Ivan Gotovchits
170+
Depends: libbap
171+
Priority: optional
172+
Version: $BAP_VERSION
173+
Description: Binary Analysis Platform C Library
174+
EOF
175+
176+
cat > $DEBIAN/postinst <<EOF
177+
#!/bin/sh
178+
ln -sf $PREFIX/lib/libbap.so.$BAP_VERSION $PREFIX/lib/libbap.so
179+
sudo ldconfig
180+
EOF
181+
182+
cat > $DEBIAN/postrm <<EOF
183+
#!/bin/sh
184+
sudo ldconfig
185+
EOF
186+
187+
chmod a+x $DEBIAN/postinst
188+
chmod a+x $DEBIAN/postrm
189+
sudo chown -R root:root bap/libbap-dev_$BAP_VERSION
190+
dpkg-deb --build bap/libbap-dev_$BAP_VERSION
191+
192+
cd bap/
193+
curl -L $SIGURL/sigs.zip > sigs.zip
194+
curl -L $SIGURL/sigs.tar.gz > sigs.tar.gz
195+
196+
for pkg in bap libbap libbap-dev; do
197+
deb=$pkg\_$BAP_VERSION
198+
dir=$pkg-$BAP_VERSION
199+
sudo alien --to-rpm -g $deb.deb
200+
cd $dir
201+
spec=$(mktemp)
202+
awk '/%dir.*bap/ {print} /%dir/ {next} {print}' $pkg-$BAP_VERSION-2.spec > $spec
203+
sudo cp $spec $pkg-$BAP_VERSION-2.spec
204+
sudo rpmbuild -bb $pkg-$BAP_VERSION-2.spec --buildroot=$(pwd)
205+
echo "trying to run alien"
206+
echo alien --to-tgz $deb.deb
207+
cd ..
208+
ls -l
209+
alien --to-tgz $deb.deb
210+
sudo rm -rf $dir
211+
done

0 commit comments

Comments
 (0)