Skip to content

Commit 32811d4

Browse files
committed
Release automation
1 parent e9cf758 commit 32811d4

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
name: Build and release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
- name: Get the version
16+
id: get_version
17+
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
18+
- name: Test on PG11
19+
run: env USE_DOCKER=1 POSTGRES_VERSION=11 ./build-and-test.sh
20+
- name: Test on PG12
21+
run: env USE_DOCKER=1 POSTGRES_VERSION=12 ./build-and-test.sh
22+
- name: Build for PG11
23+
run: env POSTGRES_VERSION=11 ./docker-build-dist.sh
24+
- name: Build for PG12
25+
run: env POSTGRES_VERSION=12 ./docker-build-dist.sh
26+
- name: Create Release
27+
id: create_release
28+
uses: actions/create-release@v1
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
tag_name: ${{ github.ref }}
33+
release_name: ${{ steps.get_version.outputs.VERSION }}
34+
draft: false
35+
prerelease: false
36+
- name: Upload PG11 tarball
37+
uses: actions/upload-release-asset@v1
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
upload_url: ${{ steps.create_release.outputs.upload_url }}
42+
asset_path: ./dist/postgres-protobuf-${{ steps.get_version.outputs.VERSION }}-linux-x86_64-for-pg11.tar.gz
43+
asset_name: postgres-protobuf-${{ steps.get_version.outputs.VERSION }}-linux-x86_64-for-pg11.tar.gz
44+
asset_content_type: application/gzip
45+
- name: Upload PG12 tarball
46+
uses: actions/upload-release-asset@v1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
upload_url: ${{ steps.create_release.outputs.upload_url }}
51+
asset_path: ./dist/postgres-protobuf-${{ steps.get_version.outputs.VERSION }}-linux-x86_64-for-pg12.tar.gz
52+
asset_name: postgres-protobuf-${{ steps.get_version.outputs.VERSION }}-linux-x86_64-for-pg12.tar.gz
53+
asset_content_type: application/gzip

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ ifndef PG_CONFIG
2828
PG_CONFIG := pg_config
2929
endif
3030

31+
PLATFORM := "$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m)"
32+
3133
PGXS := $(shell $(PG_CONFIG) --pgxs)
3234
include $(PGXS)
3335

@@ -66,15 +68,16 @@ COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CPPFLAGS) $(CP
6668
$(COMPILE.cxx.bc) -o $@ $<
6769
$(LLVM_BINPATH)/opt -module-summary -f $@ -o $@
6870

69-
DIST_TAR_BASENAME = postgres-protobuf-v$(EXT_VERSION)-for-pg$(MAJORVERSION)
71+
DIST_TAR_BASENAME = postgres-protobuf-v$(EXT_VERSION)-$(PLATFORM)-for-pg$(MAJORVERSION)
7072
DIST_DIR = dist/$(DIST_TAR_BASENAME)
7173
dist: all
7274
rm -Rf dist
73-
mkdir -p $(DIST_DIR)/lib $(DIST_DIR)/extension $(DIST_DIR)/lib/bitcode
75+
mkdir -p $(DIST_DIR)/lib $(DIST_DIR)/lib/bitcode $(DIST_DIR)/extension $(DIST_DIR)/doc
7476
cp postgres_protobuf.so $(DIST_DIR)/lib/
7577
cp postgres_protobuf.control $(DIST_DIR)/extension/
7678
cp postgres_protobuf--*.sql $(DIST_DIR)/extension/
77-
cp README.md LICENSE.txt $(DIST_DIR)/extension/
79+
cp README.md $(DIST_DIR)/doc/postgres-protobuf-README.md
80+
cp LICENSE.txt $(DIST_DIR)/doc/postgres-protobuf-LICENSE.txt
7881
cp *.bc $(DIST_DIR)/lib/bitcode/
7982
cd $(DIST_DIR)/lib/bitcode && $(LLVM_BINPATH)/llvm-lto -thinlto -thinlto-action=thinlink -o postgres_protobuf.index.bc *.bc
8083
tar -C dist -cvzf dist/$(DIST_TAR_BASENAME).tar.gz $(DIST_TAR_BASENAME)

docker-build-dist.sh

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

88
mkdir -p dist
99
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/'
10+
docker run -i --rm --volume "$(pwd)/dist:/out" postgres-protobuf-build:"${POSTGRES_VERSION}" pg_config --version
11+
docker run -i --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)