Skip to content

Build release artifacts #42

Build release artifacts

Build release artifacts #42

# MATRIX NOTES:
# At the time of this writing, Github Actions YAML does not allow for the declaration and sharing of variables
# across different jobs "easily". For example, the 'pg_version' strategy.matrix variable needs to be the same
# across all jobs, but at this time there is no way to declare an array of anything once and share it across
# several jobs.
# Therefore, any time a change is needed to strategy.matrix.pg_version (such as the case of adding or removing
# a new version of Postgres), it needs to be changed everywhere in this file as well.
name: Build release artifacts
# workflow_dispatch is also included here so that we can run this workflow at any time against a specific branch/tag
on:
release:
types: [published]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
x86_64_deb_artifacts:
name: Build x86_64 Debian artifacts
runs-on: ubuntu-latest
strategy:
matrix:
pg_version: [pg13, pg14, pg15, pg16] # See MATRIX NOTES above
fail-fast: false
permissions:
contents: write
steps:
- uses: actions/checkout@v3
# The default installation of Docker on Github Actions runners are pretty outdated, as the artifact builder
# Dockerfiles require a newer version of Docker that has heredoc support. This may not be necesssary in the future,
# but it is definitely needed at the time of this writing.
- name: Install newer version of Docker
run: |
echo "-- Remove existing installations of Docker --"
sudo apt-get remove docker docker-engine docker.io containerd runc
echo "-- Install new version -- "
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- name: Build and extract Debian .deb artifact via Docker
run: |
echo "-- Setting variables --"
export PG_VER=$(echo ${{ matrix.pg_version}} | cut -c 3-)
export PLRUST_VER=$( echo "${{ github.ref_name }}" | sed -e s/^v// )
echo "-- Building artifact via Docker --"
docker build \
--build-arg PG_VER=$PG_VER \
--build-arg PLRUST_VER=$PLRUST_VER\
-f .github/docker/Dockerfile.debian-artifact-build \
-t plrust-debian \
.
echo "-- Creating container --"
container_id=$(docker create plrust-debian)
echo "-- Extracting file from container --"
docker cp $container_id:/out /home/runner
echo "-- Destroying container --"
docker rm -v $container_id
- name: Upload Debian .deb artifact
uses: softprops/action-gh-release@v1
with:
files: /home/runner/out/plrust*.deb
arm64_deb_artifacts:
name: Build aarch64 Debian artifacts
runs-on: [self-hosted, linux, ARM64, launch_template_id__lt-0bad2911d6aad1b0d]
strategy:
matrix:
pg_version: [pg13, pg14, pg15, pg16] # See MATRIX NOTES above
fail-fast: false
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Set up docker to point to the EBS volume
sudo service docker stop
echo '{"data-root": "/workdir/.dockerdata"}' | sudo tee -a /etc/docker/daemon.json > /dev/null
sudo service docker start
- name: Build and extract Debian .deb artifact via Docker
run: |
echo "-- Setting variables --"
export PG_VER=$(echo ${{ matrix.pg_version}} | cut -c 3-)
export PLRUST_VER=$( echo "${{ github.ref_name }}" | sed -e s/^v// )
echo "-- Building artifact via Docker --"
sudo docker build \
--build-arg PG_VER=$PG_VER \
--build-arg PLRUST_VER=$PLRUST_VER \
-f .github/docker/Dockerfile.debian-artifact-build \
-t plrust-artifact-debian \
.
echo "-- Creating container --"
container_id=$(sudo docker create plrust-artifact-debian)
echo "-- Extracting file from container --"
sudo docker cp $container_id:/out /home/ubuntu
echo "-- Destroying container --"
sudo docker rm -v $container_id
- name: Upload Debian .deb artifact
uses: softprops/action-gh-release@v1
with:
files: /home/ubuntu/out/*.deb