Skip to content

Commit 545d14b

Browse files
authored
Binary release workflow. (#186)
* Add GitHub workflow for building and publishing artifacts. * Debian packaging related cleanups. * Add prepare_release script to set up autoconf version and refresh manual page.
1 parent 5d31bec commit 545d14b

File tree

9 files changed

+250
-21
lines changed

9 files changed

+250
-21
lines changed

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Build and Publish to APT
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-source-package:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
dist: [jammy, focal, bionic, bookworm, bullseye, buster]
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
path: sources
17+
- name: Install dependencies
18+
run: |
19+
sudo apt-get update && \
20+
sudo apt-get install \
21+
debhelper dput libevent-dev libpcre2-dev libssl-dev pkg-config
22+
- name: Create changelog
23+
env:
24+
VERSION: ${{ github.event.release.tag_name }}
25+
DIST: ${{ matrix.dist }}
26+
run: |
27+
mkdir -p sources/debian
28+
(echo "memtier-benchmark ($VERSION~$DIST) $DIST; urgency=medium"
29+
echo ""
30+
echo " * Release ${{ github.event.release.tag_name }}: ${{ github.event.release.html_url }}"
31+
echo ""
32+
echo " -- Redis Team <[email protected]> $(date -R)") > sources/debian/changelog
33+
- name: Build source package
34+
run: |
35+
cd sources && dpkg-buildpackage -S
36+
- name: Upload source package artifact
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: source-${{ matrix.dist }}
40+
path: |
41+
*.debian.tar.*
42+
*.dsc
43+
memtier-benchmark_*.tar.*
44+
45+
build-binary-package:
46+
runs-on: ubuntu-latest
47+
environment: build
48+
strategy:
49+
matrix:
50+
dist: [jammy, focal, bionic, bookworm, bullseye, buster]
51+
arch: [i386, amd64, arm64, armhf]
52+
exclude:
53+
- dist: focal
54+
arch: i386
55+
- dist: jammy
56+
arch: i386
57+
needs: build-source-package
58+
steps:
59+
- uses: actions/checkout@v2
60+
- name: Determine build architecture
61+
run: |
62+
if [ ${{ matrix.arch }} = "i386" ]; then
63+
BUILD_ARCH=i386
64+
else
65+
BUILD_ARCH=amd64
66+
fi
67+
echo "BUILD_ARCH=${BUILD_ARCH}" >> $GITHUB_ENV
68+
- name: Setup APT Signing key
69+
run: |
70+
mkdir -m 0700 -p ~/.gnupg
71+
echo "$APT_SIGNING_KEY" | gpg --import
72+
env:
73+
APT_SIGNING_KEY: ${{ secrets.APT_SIGNING_KEY }}
74+
- name: Install dependencies
75+
run: |
76+
sudo apt-get update && \
77+
sudo apt-get install \
78+
sbuild debhelper
79+
sudo sbuild-adduser $USER
80+
- name: Prepare sbuild environment
81+
run: sudo ./debian/setup_sbuild.sh ${{ matrix.dist }} ${{ env.BUILD_ARCH }}
82+
- name: Get source package
83+
uses: actions/download-artifact@v2
84+
with:
85+
name: source-${{ matrix.dist }}
86+
- name: Build binary package
87+
run: |
88+
sudo sbuild \
89+
--nolog \
90+
--host ${{ matrix.arch }} \
91+
--build ${{ env.BUILD_ARCH }} \
92+
--dist ${{ matrix.dist }} *.dsc
93+
- name: Upload binary package artifact
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: binary-${{ matrix.dist }}-${{ matrix.arch }}
97+
path: |
98+
*.deb
99+
- name: Upload as release assets
100+
uses: softprops/action-gh-release@v1
101+
with:
102+
files: |
103+
*.deb
104+
105+
smoke-test-packages:
106+
runs-on: ubuntu-latest
107+
needs: build-binary-package
108+
env:
109+
ARCH: amd64
110+
strategy:
111+
matrix:
112+
image: ["ubuntu:jammy", "ubuntu:focal", "ubuntu:bionic", "debian:bookworm", "debian:bullseye", "ubuntu:bionic"]
113+
container: ${{ matrix.image }}
114+
steps:
115+
- name: Get binary packages
116+
uses: actions/download-artifact@v2
117+
- name: Install packages
118+
run: |
119+
apt-get update
120+
cd binary-$(echo ${{ matrix.image }} | cut -d: -f2)-${{ env.ARCH }} && apt install --yes ./*.deb
121+
122+
publish-to-apt:
123+
if: github.event.release.prerelease == false
124+
env:
125+
DEB_S3_VERSION: "0.11.3"
126+
runs-on: ubuntu-latest
127+
environment: build
128+
needs: smoke-test-packages
129+
steps:
130+
- name: Setup APT Signing key
131+
run: |
132+
mkdir -m 0700 -p ~/.gnupg
133+
echo "$APT_SIGNING_KEY" | gpg --import
134+
env:
135+
APT_SIGNING_KEY: ${{ secrets.APT_SIGNING_KEY }}
136+
- name: Get binary packages
137+
uses: actions/download-artifact@v2
138+
- name: Setup ruby
139+
uses: actions/setup-ruby@v1
140+
with:
141+
ruby-version: "2.7"
142+
- name: Install deb-s3
143+
run: |
144+
curl -sLO https://github.com/deb-s3/deb-s3/releases/download/${{ env.DEB_S3_VERSION }}/deb-s3-${{ env.DEB_S3_VERSION }}.gem
145+
gem install deb-s3-${{ env.DEB_S3_VERSION }}.gem
146+
- name: Upload packages
147+
run: |
148+
# Quick hack to deal with duplicate _all packages
149+
rm -f binary-*-i386/*_all.deb
150+
for dir in binary-*; do \
151+
dist=$(echo $dir | cut -d- -f 2) ; \
152+
deb-s3 upload \
153+
--bucket ${{ secrets.APT_S3_BUCKET }} \
154+
--s3-region ${{ secrets.APT_S3_REGION }} \
155+
--codename $dist \
156+
--preserve-versions \
157+
--fail-if-exists \
158+
--sign \
159+
--prefix deb \
160+
$dir/*.deb ; \
161+
done
162+
env:
163+
AWS_ACCESS_KEY_ID: ${{ secrets.APT_S3_ACCESS_KEY_ID }}
164+
AWS_SECRET_ACCESS_KEY: ${{ secrets.APT_S3_SECRET_ACCESS_KEY }}

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public License
1616
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
AC_PREREQ(2.59)
19-
AC_INIT(memtier_benchmark,1.3.0,yossigo@gmail.com)
19+
AC_INIT(memtier_benchmark,1.3.0,oss@redis.com)
2020
AC_CONFIG_SRCDIR([memtier_benchmark.cpp])
2121
AC_CONFIG_HEADER([config.h])
2222
AM_INIT_AUTOMAKE
@@ -82,7 +82,7 @@ PKG_CHECK_MODULES(LIBEVENT,
8282
# bash completion
8383
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
8484
[BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
85-
[BASH_COMPLETION_DIR="$datadir/bash-completion/completionsss"])
85+
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
8686
AC_SUBST([BASH_COMPLETION_DIR])
8787

8888
AC_CONFIG_FILES([

debian/changelog

Lines changed: 0 additions & 5 deletions
This file was deleted.

debian/control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Source: memtier-benchmark
22
Section: admin
33
Priority: optional
4-
Maintainer: Redis Labs <[email protected]>
5-
Build-Depends: debhelper-compat (= 12), dh-autoreconf, bash-completion, pkg-config, libpcre3-dev, libevent-dev, libssl-dev, zlib1g-dev
4+
Maintainer: Redis Ltd. <[email protected]>
5+
Build-Depends: debhelper-compat (= 10), dh-autoreconf, bash-completion, pkg-config, libpcre3-dev, libevent-dev, libssl-dev, zlib1g-dev
66
Standards-Version: 4.4.1
77
Homepage: https://github.com/RedisLabs/memtier_benchmark
88

debian/copyright

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
22
Upstream-Name: memtier-benchmark
3-
Upstream-Contact: Redis Labs Open Source <[email protected]>
3+
Upstream-Contact: Redis Ltd. <[email protected]>
44
Source: https://github.com/RedisLabs/memtier_benchmark
55

66
Files: *
7-
Copyright: 2011-2020 Redis Labs <[email protected]>
8-
License: GPL-2.0+
7+
Copyright: 2011-2020 Redis Ltd. <[email protected]>
8+
License: GPL-2+ with OpenSSL Exception
9+
10+
Files: deps/hdr_histogram/*
11+
Copyright: 2012-2014, Gil Tene
12+
2014, Matt Warren
13+
2014, Michael Barker
14+
License: CC0-1.0
915

1016
Files: debian/*
11-
Copyright: 2020 Redis Labs <[email protected]>
17+
Copyright: 2020 Redis Ltd. <[email protected]>
1218
License: GPL-2.0+
1319

14-
License: GPL-2.0+
1520
This package is free software; you can redistribute it and/or modify
1621
it under the terms of the GNU General Public License as published by
1722
the Free Software Foundation; either version 2 of the License, or
@@ -39,3 +44,6 @@ License: GPL-2.0+
3944
obligated to do so. If you do not wish to do so, delete this exception
4045
statement from your version. If you delete this exception statement from all
4146
source files in the program, then also delete it here.
47+
48+
License: CC0-1.0
49+
See "/usr/share/common-licenses/CC0-1.0".

debian/setup_sbuild.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
#!/bin/bash
3+
if [ $# != 2 ]; then
4+
echo "Please use: setup_build.sh [dist] [arch]"
5+
exit 1
6+
fi
7+
8+
dist="$1"
9+
arch="$2"
10+
if ubuntu-distro-info --all | grep -Fqx "$dist"; then
11+
disttype="ubuntu"
12+
else
13+
disttype="debian"
14+
fi
15+
16+
# Determine base apt repository URL based on type of distribution.
17+
case "$disttype" in
18+
ubuntu)
19+
url=http://archive.ubuntu.com/ubuntu
20+
;;
21+
debian)
22+
url=http://deb.debian.org/debian
23+
;;
24+
*)
25+
echo "Unknown distribution $disttype"
26+
exit 1
27+
esac
28+
29+
sbuild-createchroot \
30+
--arch ${arch} --make-sbuild-tarball=/var/lib/sbuild/${dist}-${arch}.tar.gz \
31+
${dist} `mktemp -d` ${url}
32+
33+
# Ubuntu has the main and ports repositories on different URLs, so we need to
34+
# properly set up /etc/apt/sources.list to make cross compilation work.
35+
if [ "$disttype" = "ubuntu" ]; then
36+
cat <<__END__ | schroot -c source:${dist}-${arch}-sbuild -d / -- tee /etc/apt/sources.list
37+
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu ${dist} main universe
38+
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu ${dist}-updates main universe
39+
deb [arch=armhf,arm64] http://ports.ubuntu.com ${dist} main universe
40+
deb [arch=armhf,arm64] http://ports.ubuntu.com ${dist}-updates main universe
41+
__END__
42+
fi

debian/watch

Lines changed: 0 additions & 5 deletions
This file was deleted.

memtier_benchmark.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
481481
break;
482482
case 'v':
483483
puts(PACKAGE_STRING);
484-
// FIXME!!
485-
puts("Copyright (C) 2011-2020 Redis Labs Ltd.");
484+
puts("Copyright (C) 2011-2022 Redis Ltd.");
486485
puts("This is free software. You may redistribute copies of it under the terms of");
487486
puts("the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.");
488487
puts("There is NO WARRANTY, to the extent permitted by law.");

utils/prepare_release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
if [ $# != 1 ]; then
3+
echo "usage: prepare_release.sh [release]"
4+
exit 1
5+
fi
6+
RELEASE="$1"
7+
8+
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
9+
echo "Please commit or revert all local changes before preparing a release."
10+
exit 1
11+
fi
12+
13+
set -e
14+
15+
# Update configure.ac version
16+
sed -i 's/^\(AC_INIT(.*\),.*,\(.*)\)$/\1,'$RELEASE',\2/' configure.ac
17+
18+
# Build
19+
autoreconf -ivf
20+
./configure
21+
make
22+
make rebuild-man
23+
24+
# Commit
25+
git add configure.ac memtier_benchmark.1
26+
git commit -m "Release $RELEASE"

0 commit comments

Comments
 (0)