-
Notifications
You must be signed in to change notification settings - Fork 9
96 lines (91 loc) · 3.23 KB
/
build-deb.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
name: Build and Release Package
on: [push]
env:
MAINTAINER_NAME: "Andriel Nuernberg"
MAINTAINER_EMAIL: "andrielfn@gmail.com"
GITHUB_USERNAME: "andrielfn"
VERSION: "0.0.1"
PG_VERSION: "16"
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build package
uses: ./.github/actions/build-deb
env:
MAINTAINER_NAME: ${{ env.MAINTAINER_NAME }}
MAINTAINER_EMAIL: ${{ env.MAINTAINER_EMAIL }}
GITHUB_USERNAME: ${{ env.GITHUB_USERNAME }}
VERSION: ${{ env.VERSION }}
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: postgresql-ulid-deb
path: ./*.deb
test:
name: Test
needs: build
runs-on: ubuntu-22.04
steps:
- name: Download package
uses: actions/download-artifact@v4
with:
name: postgresql-ulid-deb
- name: Remove pre-existing PostgreSQL installations
run: |
sudo apt-get remove -y postgresql postgresql-contrib
sudo apt-get autoremove -y
sudo rm -rf /var/lib/postgresql/
sudo rm -rf /etc/postgresql/
sudo rm -rf /etc/postgresql-common/
- name: Install PostgreSQL
run: |
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 --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-${{ env.PG_VERSION }} postgresql-contrib-${{ env.PG_VERSION }}
- name: Install package
run: |
sudo dpkg -i *.deb
sudo apt-get install -f
- name: Verify PostgreSQL and extension installation
run: |
psql --version
sudo dpkg -L postgresql-${{ env.PG_VERSION }}-ulid
ls -l /usr/share/postgresql/${{ env.PG_VERSION }}/extension/ | grep ulid
- name: Start PostgreSQL service
run: |
sudo systemctl start postgresql
sudo systemctl status postgresql
- name: Test PostgreSQL extension
run: |
sudo -u postgres psql -c "SHOW server_version;"
sudo -u postgres psql -c "SHOW data_directory;"
sudo -u postgres psql -c "CREATE EXTENSION ulid;"
sudo -u postgres psql -c "SELECT gen_ulid();"
sudo -u postgres psql -c "SELECT '01H55TNAQ96WPSWE6WZRCH9G0C'::ulid::timestamp;"
release:
name: Create Release
needs: [build, test]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Download package
uses: actions/download-artifact@v4
with:
name: postgresql-ulid-deb
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "postgresql-${{ env.PG_VERSION }}-ulid_${{ env.VERSION }}_amd64.deb"
name: Release ${{ env.COMMIT_SHORT_SHA }}
tag: ${{ env.COMMIT_SHORT_SHA }}
draft: false
prerelease: false