Skip to content

Commit c9acd4f

Browse files
authored
Merge pull request #19 from supabase/or/release-ci
Build install artifacts on CI
2 parents f2fcb57 + 59c7479 commit c9acd4f

File tree

2 files changed

+128
-1
lines changed

2 files changed

+128
-1
lines changed

.github/workflows/release.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
4+
on:
5+
push:
6+
# Sequence of patterns matched against refs/tags
7+
tags:
8+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
9+
10+
jobs:
11+
release:
12+
name: Create Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
- name: Create Release
18+
id: create_release
19+
uses: actions/create-release@v1
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
with:
23+
tag_name: ${{ github.ref }}
24+
release_name: ${{ github.ref }}
25+
body: |
26+
Changes in this Release
27+
- First Change
28+
- Second Change
29+
draft: false
30+
prerelease: false
31+
32+
build-linux-gnu:
33+
name: release artifacts
34+
needs:
35+
- release
36+
strategy:
37+
matrix:
38+
extension_name:
39+
- pg_jsonschema
40+
package_name:
41+
- pg-jsonschema
42+
pgx_version:
43+
- 0.6.0-alpha.1
44+
postgres: [14, 15]
45+
box:
46+
- { runner: ubuntu-20.04, arch: amd64 }
47+
- { runner: arm-runner, arch: arm64 }
48+
runs-on: ${{ matrix.box.runner }}
49+
timeout-minutes: 45
50+
steps:
51+
- uses: actions/checkout@v3
52+
53+
- name: build release artifacts
54+
run: |
55+
# Add postgres package repo
56+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
57+
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
58+
59+
sudo apt-get update
60+
sudo apt-get install -y --no-install-recommends git build-essential libpq-dev curl libreadline6-dev zlib1g-dev pkg-config cmake
61+
sudo apt-get install -y --no-install-recommends libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache
62+
sudo apt-get install -y --no-install-recommends clang libclang-dev gcc
63+
64+
# Install requested postgres version
65+
sudo apt install -y postgresql-${{ matrix.postgres }} postgresql-server-dev-${{ matrix.postgres }} -y
66+
67+
# Ensure installed pg_config is first on path
68+
export PATH=$PATH:/usr/lib/postgresql/${{ matrix.postgres }}/bin
69+
70+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain nightly && \
71+
rustup --version && \
72+
rustc --version && \
73+
cargo --version
74+
75+
# Ensure cargo/rust on path
76+
source "$HOME/.cargo/env"
77+
78+
cargo install cargo-pgx --version ${{ matrix.pgx_version }} --locked
79+
cargo pgx init --pg${{ matrix.postgres }}=/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config
80+
81+
# selects the pgVer from pg_config on path
82+
# https://github.com/tcdi/pgx/issues/288
83+
cargo pgx package --no-default-features --features pg${{ matrix.postgres }}
84+
85+
# Create installable package
86+
mkdir archive
87+
cp `find target/release -type f -name "${{ matrix.extension_name }}*"` archive
88+
89+
# Create directory structure
90+
mkdir -p ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/usr/lib/postgresql/lib
91+
mkdir -p ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/var/lib/postgresql/extension
92+
93+
# Copy files into directory structure
94+
cp archive/*.so ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/usr/lib/postgresql/lib
95+
cp archive/*.control ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/var/lib/postgresql/extension
96+
cp archive/*.sql ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/var/lib/postgresql/extension
97+
98+
# Create install control file
99+
extension_version=${{ github.ref_name }}
100+
# strip the leading v
101+
deb_version=${extension_version:1}
102+
103+
mkdir -p ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN
104+
touch ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
105+
echo 'Package: ${{ matrix.package_name }}' >> ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
106+
echo 'Version:' ${deb_version} >> ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
107+
echo 'Architecture: ${{ matrix.box.arch }}' >> ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
108+
echo 'Maintainer: supabase' >> ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
109+
echo 'Description: A PostgreSQL extension' >> ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu/DEBIAN/control
110+
111+
# Create deb package
112+
sudo chown -R root:root ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu
113+
sudo chmod -R 00755 ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu
114+
sudo dpkg-deb --build --root-owner-group ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu
115+
116+
- name: Get upload url
117+
run: echo UPLOAD_URL=$(curl --silent https://api.github.com/repos/${{ github.repository }}/releases/latest | jq .upload_url --raw-output) >> $GITHUB_ENV
118+
119+
- name: Upload release asset
120+
uses: actions/upload-release-asset@v1
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
with:
124+
upload_url: ${{ env.UPLOAD_URL }}
125+
asset_path: ./${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb
126+
asset_name: ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb
127+
asset_content_type: application/vnd.debian.binary-package

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pg_jsonschema"
3-
version = "0.1.1"
3+
version = "0.1.3"
44
edition = "2021"
55

66
[lib]

0 commit comments

Comments
 (0)