Skip to content

Commit e9cf758

Browse files
committed
Script to build tarballs in Docker
1 parent 0aa7208 commit e9cf758

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

Dockerfile.test renamed to Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ RUN apt-get update \
2828
&& sudo -u postgres createuser -s root
2929

3030
COPY /test_protos /app/test_protos
31-
COPY Makefile *.hpp *.cpp *.rb *.sh *.sql *.control *.md /app/
31+
COPY Makefile *.hpp *.cpp *.rb *.sh *.sql *.control *.md *.txt /app/
32+
RUN cd /app && make clean && make -j16 dist

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,17 @@ COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CPPFLAGS) $(CP
6666
$(COMPILE.cxx.bc) -o $@ $<
6767
$(LLVM_BINPATH)/opt -module-summary -f $@ -o $@
6868

69-
DIST_DIR = dist/postgres-protobuf-$(EXT_VERSION)
69+
DIST_TAR_BASENAME = postgres-protobuf-v$(EXT_VERSION)-for-pg$(MAJORVERSION)
70+
DIST_DIR = dist/$(DIST_TAR_BASENAME)
7071
dist: all
7172
rm -Rf dist
7273
mkdir -p $(DIST_DIR)/lib $(DIST_DIR)/extension $(DIST_DIR)/lib/bitcode
7374
cp postgres_protobuf.so $(DIST_DIR)/lib/
7475
cp postgres_protobuf.control $(DIST_DIR)/extension/
7576
cp postgres_protobuf--*.sql $(DIST_DIR)/extension/
76-
cp README.md $(DIST_DIR)/extension/
77+
cp README.md LICENSE.txt $(DIST_DIR)/extension/
7778
cp *.bc $(DIST_DIR)/lib/bitcode/
7879
cd $(DIST_DIR)/lib/bitcode && $(LLVM_BINPATH)/llvm-lto -thinlto -thinlto-action=thinlink -o postgres_protobuf.index.bc *.bc
79-
tar -C dist -cvzf dist/postgres-protobuf-$(EXT_VERSION).tar.gz postgres-protobuf-$(EXT_VERSION)
80+
tar -C dist -cvzf dist/$(DIST_TAR_BASENAME).tar.gz $(DIST_TAR_BASENAME)
8081

8182
.PHONY: all clean protoc postgres_protobuf_clean dist

build-and-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ POSTGRES_VERSION=${POSTGRES_VERSION:-11}
77

88
if [[ -n "${USE_DOCKER:-}" ]]; then
99
unset USE_DOCKER
10-
docker build -f Dockerfile.test --build-arg=POSTGRES_VERSION="${POSTGRES_VERSION}" -t postgres-protobuf-test:"${POSTGRES_VERSION}" .
11-
docker run postgres-protobuf-test:"${POSTGRES_VERSION}" env __IN_DOCKER=1 /app/build-and-test.sh
10+
docker build --build-arg=POSTGRES_VERSION="${POSTGRES_VERSION}" -t postgres-protobuf-build:"${POSTGRES_VERSION}" .
11+
docker run postgres-protobuf-build:"${POSTGRES_VERSION}" env NO_CLEAN=1 __IN_DOCKER=1 /app/build-and-test.sh
1212
exit $?
1313
fi
1414

docker-build-dist.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
cd "$(dirname "${0}")"
5+
6+
POSTGRES_VERSION=${POSTGRES_VERSION:-11}
7+
8+
mkdir -p dist
9+
docker build --build-arg=POSTGRES_VERSION="${POSTGRES_VERSION}" -t postgres-protobuf-build:"${POSTGRES_VERSION}" .
10+
docker run -it --rm --volume "$(pwd)/dist:/out" postgres-protobuf-build:"${POSTGRES_VERSION}" pg_config --version
11+
docker run -it --rm --volume "$(pwd)/dist:/out" postgres-protobuf-build:"${POSTGRES_VERSION}" /bin/bash -c 'cp -f /app/dist/*.tar.gz /out/'

0 commit comments

Comments
 (0)