-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: added github action for binary releases (#16)
- Loading branch information
Showing
4 changed files
with
175 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: Build, Upload and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- ci/release-binary | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build-and-upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Build Docker image for AMD64 and ARM64 | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
tags: mumak:latest | ||
push: false | ||
platforms: linux/amd64 | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache | ||
load: true | ||
|
||
- name: Run Docker container and extract artifacts (AMD64) | ||
run: | | ||
docker run -e POSTGRES_PASSWORD=password -d --name app mumak:latest | ||
mkdir -p artifacts | ||
docker cp app:/source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak.control ./artifacts/ | ||
docker cp app:/source/target/release/mumak-pg16/usr/lib/postgresql/16/lib/mumak.so ./artifacts/ | ||
SQL_FILE=$(docker exec app sh -c "ls /source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak--*.sql") | ||
docker cp "app:$SQL_FILE" ./artifacts/ | ||
docker stop app | ||
tar -czvf mumak-artifacts-amd64.tar.gz -C artifacts . | ||
- name: Upload Tarred Artifacts (AMD64) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: mumak-artifacts-amd64 | ||
path: ./mumak-artifacts-amd64.tar.gz | ||
|
||
# - name: Run Docker container and extract artifacts (ARM64) | ||
# run: | | ||
# docker run -e POSTGRES_PASSWORD=password -d --name app-arm mumak:latest | ||
# mkdir -p artifacts-arm | ||
# docker cp app-arm:/source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak.control ./artifacts-arm/ | ||
# docker cp app-arm:/source/target/release/mumak-pg16/usr/lib/postgresql/16/lib/mumak.so ./artifacts-arm/ | ||
# SQL_FILE=$(docker exec app-arm sh -c "ls /source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak--*.sql") | ||
# docker cp "app-arm:$SQL_FILE" ./artifacts-arm/ | ||
# docker stop app-arm | ||
# tar -czvf mumak-artifacts-arm64.tar.gz -C artifacts-arm . | ||
|
||
# - name: Upload Tarred Artifacts (ARM64) | ||
# uses: actions/upload-artifact@v2 | ||
# with: | ||
# name: mumak-artifacts-arm64 | ||
# path: ./mumak-artifacts-arm64.tar.gz | ||
|
||
release: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: build-and-upload | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Tarred Artifacts (AMD64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: mumak-artifacts-amd64 | ||
|
||
# - name: Download Tarred Artifacts (ARM64) | ||
# uses: actions/download-artifact@v2 | ||
# with: | ||
# name: mumak-artifacts-arm64 | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset (AMD64) | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./mumak-artifacts-amd64.tar.gz | ||
asset_name: mumak-artifacts-amd64.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
# - name: Upload Release Asset (ARM64) | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ./mumak-artifacts-arm64.tar.gz | ||
# asset_name: mumak-artifacts-arm64.tar.gz | ||
# asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM postgres:16 | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
RUN usermod -u $UID postgres && groupmod -g $GID postgres | ||
RUN apt update && apt -y install \ | ||
curl \ | ||
git \ | ||
libclang-dev \ | ||
build-essential \ | ||
libreadline-dev \ | ||
zlib1g-dev \ | ||
flex \ | ||
bison \ | ||
libxml2-dev \ | ||
libxslt-dev \ | ||
libssl-dev \ | ||
libxml2-utils \ | ||
xsltproc \ | ||
ccache \ | ||
pkg-config \ | ||
sudo | ||
|
||
# Temporary to make vscode extension work since its running under root | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
# Add postgres to the sudoers with no password prompt for specific commands | ||
RUN echo "postgres ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/postgres | ||
|
||
RUN chown -R postgres:postgres /usr/share/postgresql | ||
RUN chown -R postgres:postgres /usr/lib/postgresql | ||
# Using su instead of USER since dev container doesn't seem to like USER docker directive | ||
RUN su - postgres -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y' | ||
|
||
RUN echo 'export PATH="/var/lib/postgresql/.cargo/bin:${PATH}"' >> /var/lib/postgresql/.bashrc | ||
RUN echo 'export USER=postgres' >> /var/lib/postgresql/.bashrc | ||
|
||
RUN su - postgres -c 'cargo install --locked cargo-pgrx && cargo pgrx init' | ||
|
||
WORKDIR /source | ||
COPY ./extension ./ | ||
RUN sudo chown -R postgres:postgres /source | ||
RUN su - postgres -c 'cd /source && cargo pgrx install' | ||
|
||
COPY ./init-db.sh /docker-entrypoint-initdb.d/ |