Skip to content

Commit 17d36b4

Browse files
authored
Update Build Draft Release workflow to include creation of linux arm64 binaries. Closes #194
1 parent be02075 commit 17d36b4

File tree

5 files changed

+115
-207
lines changed

5 files changed

+115
-207
lines changed

.github/workflows/buildLinuxArmBinary.yml

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

.github/workflows/buildimage.yml

Lines changed: 106 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
if-no-files-found: error
167167

168168
build-linux:
169-
name: Build for Linux
169+
name: Build for Linux x86_64
170170
runs-on: ubuntu-latest
171171
steps:
172172
- name: Checkout
@@ -208,19 +208,23 @@ jobs:
208208
run: |-
209209
sudo apt-get -y install postgresql-server-dev-14
210210
211-
- name: Find stuff
211+
- name: Find stuff and set env
212212
run: |-
213213
214214
which pg_config
215215
pg_config --version
216216
217217
export PATH=$(pg_config --bindir):$PATH
218218
export PGXS=$(pg_config --pgxs)
219-
219+
220220
export SERVER_LIB=$(pg_config --includedir)/14/server
221221
export INTERNAL_LIB=$(pg_config --includedir)/internal
222222

223-
ls -la $(pg_config --includedir)
223+
export CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
224+
export PG_CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
225+
226+
export LDFLAGS=$(pg_config --ldflags)
227+
export PG_LDFLAGS=$(pg_config --ldflags)
224228

225229
ls -la $SERVER_LIB
226230
ls -la $INTERNAL_LIB
@@ -229,69 +233,16 @@ jobs:
229233
working-directory: ./fdw
230234
run: |-
231235
go version
232-
233-
which pg_config
234-
pg_config --version
235-
236-
export PATH=$(pg_config --bindir):$PATH
237-
export PGXS=$(pg_config --pgxs)
238-
239-
export SERVER_LIB=$(pg_config --includedir)/server
240-
export INTERNAL_LIB=$(pg_config --includedir)/internal
241-
242-
export CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
243-
export PG_CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
244-
245-
export LDFLAGS=$(pg_config --ldfalgs)
246-
export PG_LDFLAGS=$(pg_config --ldfalgs)
247-
248236
make clean
249237
250238
- name: make go
251239
working-directory: ./fdw
252240
run: |-
253-
go version
254-
255-
which pg_config
256-
pg_config --version
257-
258-
export PATH=$(pg_config --bindir):$PATH
259-
export PGXS=$(pg_config --pgxs)
260-
261-
export SERVER_LIB=$(pg_config --includedir)/postgresql/server
262-
export INTERNAL_LIB=$(pg_config --includedir)/postgresql/internal
263-
264-
export CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
265-
export PG_CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
266-
267-
export CPPFLAGS="$(pg_config --cppflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
268-
export PG_CPPFLAGS="$(pg_config --cppflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
269-
270-
export LDFLAGS=$(pg_config --ldflags)
271-
export PG_LDFLAGS=$(pg_config --ldflags)
272-
273241
make go
274242
275243
- name: make
276244
working-directory: ./fdw
277245
run: |-
278-
go version
279-
280-
which pg_config
281-
pg_config --version
282-
283-
export PATH=$(pg_config --bindir):$PATH
284-
export PGXS=$(pg_config --pgxs)
285-
286-
export SERVER_LIB=$(pg_config --includedir)/server
287-
export INTERNAL_LIB=$(pg_config --includedir)/internal
288-
289-
export CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
290-
export PG_CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
291-
292-
export LDFLAGS=$(pg_config --ldfalgs)
293-
export PG_LDFLAGS=$(pg_config --ldfalgs)
294-
295246
make
296247
297248
- name: gzip the steampipe_postgres_fdw.so
@@ -307,27 +258,109 @@ jobs:
307258
path: ./fdw/steampipe_postgres_fdw.so.linux_amd64.gz
308259
if-no-files-found: error
309260

310-
publish:
261+
build-linux-arm:
262+
name: Build for Linux ARM64
263+
runs-on: ubuntu-latest
264+
steps:
265+
- name: Checkout
266+
uses: actions/checkout@v3
267+
268+
- name: Build and upload binary
269+
uses: uraimo/run-on-arch-action@v2
270+
env:
271+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272+
with:
273+
arch: aarch64
274+
distro: ubuntu_latest
275+
# Create an artifacts directory
276+
setup: |
277+
mkdir -p "${PWD}/artifacts"
278+
# Mount the artifacts directory as /artifacts in the container
279+
dockerRunArgs: |
280+
--volume "${PWD}/artifacts:/artifacts"
281+
env: |
282+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
283+
run: |
284+
echo "update apt and install necessary packages"
285+
apt-get update -y
286+
apt-get -y install sudo git curl tar gzip file postgresql-server-dev-14 build-essential make
287+
288+
echo "install go"
289+
curl -LO https://go.dev/dl/go1.18beta1.linux-arm64.tar.gz
290+
tar -C /usr/local -xzf go1.18beta1.linux-arm64.tar.gz
291+
export GOROOT=/usr/local/go
292+
export GOPATH=$HOME/go
293+
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
294+
go version
295+
296+
echo "find stuff and set env"
297+
which pg_config
298+
pg_config --version
299+
export PATH=$(pg_config --bindir):$PATH
300+
export PGXS=$(pg_config --pgxs)
301+
export SERVER_LIB=$(pg_config --includedir)/server
302+
export INTERNAL_LIB=$(pg_config --includedir)/internal
303+
export CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
304+
export PG_CFLAGS="$(pg_config --cflags) -I${SERVER_LIB} -I${INTERNAL_LIB} -g"
305+
export LDFLAGS=$(pg_config --ldflags)
306+
export PG_LDFLAGS=$(pg_config --ldflags)
307+
308+
echo "clone repo"
309+
git clone https://github.com/turbot/steampipe-postgres-fdw.git
310+
git config --global --add safe.directory /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw
311+
git init
312+
git fetch
313+
pwd
314+
git checkout ${{ github.event.inputs.tag }}
315+
cd steampipe-postgres-fdw/fdw
316+
317+
echo "make clean"
318+
go version
319+
make clean
320+
321+
echo "make go"
322+
make go
323+
324+
echo "make"
325+
make
326+
327+
echo "check binary and copy into artifacts directory"
328+
file steampipe_postgres_fdw.so
329+
gzip steampipe_postgres_fdw.so
330+
mv steampipe_postgres_fdw.so.gz steampipe_postgres_fdw.so.linux_arm64.gz
331+
ls
332+
cp steampipe_postgres_fdw.so.linux_arm64.gz /artifacts
333+
ls -al /artifacts
334+
335+
- name: Show the artifact
336+
# Items placed in /artifacts in the container will be in
337+
# ${PWD}/artifacts on the host.
338+
run: |
339+
ls -al "${PWD}/artifacts"
340+
341+
- name: Save Linux Build Artifact - ARM64
342+
uses: actions/upload-artifact@v3
343+
with:
344+
name: steampipe_postgres_fdw.so.linux_arm64
345+
path: /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw/artifacts/steampipe_postgres_fdw.so.linux_arm64.gz
346+
if-no-files-found: error
347+
348+
build-draft-release:
349+
name: Build Draft Release
311350
runs-on: ubuntu-latest
312351
needs:
313352
- build-linux
314353
- build-osx
354+
- build-linux-arm
315355
steps:
316356

317357
- name: Get latest version tag
318358
run: |-
319359
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
320360
321-
- name: Trim tag
322-
run: |-
323-
echo $VERSION
324-
trim=${VERSION#"v"}
325-
echo $trim
326-
echo "VERSION=${trim}" >> $GITHUB_ENV
327-
328361
- name: Validate Version String
329362
run: |-
330-
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
363+
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
331364
echo "Version OK: $VERSION"
332365
else
333366
echo "Invalid version: $VERSION"
@@ -346,6 +379,12 @@ jobs:
346379
with:
347380
name: steampipe_postgres_fdw.so.linux_amd64
348381

382+
- name: Download steampipe_postgres_fdw.so - linux_arm64
383+
id: download_fdw_so_linux_arm64
384+
uses: actions/download-artifact@v3
385+
with:
386+
name: steampipe_postgres_fdw.so.linux_arm64
387+
349388
- name: Download steampipe_postgres_fdw.control
350389
id: download_fdw_control
351390
uses: actions/download-artifact@v3
@@ -375,4 +414,5 @@ jobs:
375414
${{ steps.download_fdw_sql.outputs.download-path }}/steampipe_postgres_fdw--1.0.sql
376415
${{ steps.download_fdw_control.outputs.download-path }}/steampipe_postgres_fdw.control
377416
${{ steps.download_fdw_so_linux_amd64.outputs.download-path }}/steampipe_postgres_fdw.so.linux_amd64.gz
417+
${{ steps.download_fdw_so_linux_arm64.outputs.download-path }}/steampipe_postgres_fdw.so.linux_arm64.gz
378418
${{ steps.download_fdw_so_darwin_amd64.outputs.download-path }}/steampipe_postgres_fdw.so.darwin_amd64.gz

0 commit comments

Comments
 (0)