-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (148 loc) · 6.05 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: release
on:
push:
tags:
- 'v*'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
publish-python:
environment: release # needed for PyPI OIDC
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build
run: |
pip install build
python -m build
- name: Publish
# mimics: twine upload dist/* --skip-existing
uses: pypa/gh-action-pypi-publish@release/v1
publish-rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set version
env:
RELEASE_TAG: ${{ github.ref }}
run: |
sed -i "s/0\\.0\\.999/${RELEASE_TAG##*\/v}/" upid_rs/Cargo.toml
sed -i "s/0\\.0\\.999/${RELEASE_TAG##*\/v}/" Cargo.lock
- uses: dtolnay/rust-toolchain@stable
- name: publish
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: |
cargo publish --package upid --token $CRATES_TOKEN --allow-dirty
docker-pg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract tag name
id: extract_tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Docker Buildx base image
env:
RELEASE_TAG: ${{ env.RELEASE_TAG }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--output "type=image,push=true" \
--tag "carderne/postgres-upid:16-${RELEASE_TAG}" \
--tag "carderne/postgres-upid:16" \
--tag "carderne/postgres-upid:latest" \
--cache-from "carderne/postgres-upid:latest" \
--cache-to type=inline \
.
build-pg:
# modified from this workflow:
# https://github.com/pksunkara/pgx_ulid/blob/master/.github/workflows/release.yml
needs: create-release
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
postgres: [16]
env:
NAME: upid_pg
PKG_NAME: upid-pg
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
# Add postgres package repo
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt-get update
sudo apt-get install -y --no-install-recommends git build-essential libpq-dev curl libreadline6-dev zlib1g-dev pkg-config cmake
sudo apt-get install -y --no-install-recommends libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache
sudo apt-get install -y --no-install-recommends clang libclang-dev llvm-dev gcc tree
# Install requested postgres version
sudo apt-get install -y postgresql-${{ matrix.postgres }} postgresql-server-dev-${{ matrix.postgres }} -y
# Ensure installed pg_config is first on path
export PATH=$PATH:/usr/lib/postgresql/${{ matrix.postgres }}/bin
cargo install cargo-pgrx --version 0.11.2 --locked
cargo pgrx init --pg${{ matrix.postgres }}=/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config
- name: Build
run: |
cargo pgrx package --no-default-features --features "pg${{ matrix.postgres }}" --package upid_pg
mkdir archive
cp `find target/release -type f -name "${{ env.NAME }}*"` archive
# Copy files into directory structure
mkdir -p package/usr/lib/postgresql/lib
mkdir -p package/var/lib/postgresql/extension
cp archive/*.so package/usr/lib/postgresql/lib
cp archive/*.control package/var/lib/postgresql/extension
cp archive/*.sql package/var/lib/postgresql/extension
# symlinks to Copy files into directory structure
mkdir -p package/usr/lib/postgresql/"${{ matrix.postgres }}"/lib
cd package/usr/lib/postgresql/"${{ matrix.postgres }}"/lib
cp -s ../../lib/*.so .
cd ../../../../../..
mkdir -p package/usr/share/postgresql/"${{ matrix.postgres }}"/extension
cd package/usr/share/postgresql/"${{ matrix.postgres }}"/extension
cp -s ../../../../../var/lib/postgresql/extension/"${{ env.NAME }}".control .
cp -s ../../../../../var/lib/postgresql/extension/"${{ env.NAME }}"*.sql .
cd ../../../../../..
# Create install control file
extension_version="${{ github.ref_name }}"
# strip the leading v
deb_version=${extension_version:1}
mkdir -p package/DEBIAN
touch package/DEBIAN/control
echo 'Package: ${{ env.PKG_NAME }}' >> package/DEBIAN/control
echo 'Version:' ${deb_version} >> package/DEBIAN/control
echo 'Architecture: amd64' >> package/DEBIAN/control
echo 'Maintainer: Chris Arderne' >> package/DEBIAN/control
echo 'Description: A PostgreSQL extension for UPID' >> package/DEBIAN/control
# Create deb package
sudo chown -R root:root package
sudo chmod -R 00755 package
sudo dpkg-deb -Zxz --build --root-owner-group package
- name: Upload deb to release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG=${{ github.ref_name }}
FILE=${{ env.PKG_NAME }}-${TAG}-pg16-amd64-linux-gnu.deb
mv package.deb $FILE
gh release upload "$TAG" "$FILE"