Skip to content

ci: add short git commit SHA to GitHub release #45

ci: add short git commit SHA to GitHub release

ci: add short git commit SHA to GitHub release #45

Workflow file for this run

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