Publish RonDB Tarball #10
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
name: Publish RonDB Tarball | |
on: | |
workflow_dispatch: | |
inputs: | |
release_build: | |
required: true | |
type: boolean | |
default: false | |
push: | |
branches: | |
- "21.04.[0-9]+" | |
- "22.10.[0-9]+" | |
- "24.10.[0-9]+" | |
tags: | |
- "rondb-21.04.[0-9]+" | |
- "rondb-22.10.[0-9]+" | |
- "rondb-24.10.[0-9]+" | |
# This is important because the jobs are expensive and we don't want to wait a lot of time. | |
# This cancel-in-progress only works per branch, if a previous commit launched a job, a | |
# new one will cancel it. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
publish-arm-tarball: | |
runs-on: [self-hosted, ARM64] | |
if: github.repository == 'logicalclocks/rondb' | |
env: | |
REPO_HOPSWORKS_HOSTNAME: repo.hops.works | |
REPO_HOPSWORKS_USER: repo_upload | |
# The corresponding public key is added to the authorized_keys of the | |
# repo_upload user on the repo.hops.works server | |
SSH_PRIVATE_KEY: ${{ secrets.REPO_UPLOAD_SSH_PRIVATE_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- run: cat ./MYSQL_VERSION | |
- name: Extract Git tag | |
if: startsWith(github.ref, 'refs/tags/rondb-') | |
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/rondb-}" >> $GITHUB_ENV | |
- name: Verify RONDB_VERSION | |
if: startsWith(github.ref, 'refs/tags/rondb-') | |
shell: bash | |
run: | | |
source ./MYSQL_VERSION | |
RONDB_VERSION="$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH" | |
if [ "$RONDB_VERSION" != "$TAG_NAME" ]; then | |
echo "Error: RONDB_VERSION ($RONDB_VERSION) does not match the tag version ($TAG_NAME)" | |
exit 1 | |
fi | |
- name: Set up SSH | |
run: | | |
mkdir -p "$HOME/.ssh" | |
echo "$SSH_PRIVATE_KEY" > "$HOME/.ssh/id_ed25519" | |
chmod 600 "$HOME/.ssh/id_ed25519" | |
REPO_PUBLIC_KEY="repo.hops.works ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAvVvdl0/YDPeKNbg0AnCQQcFIXJV2WhuxcgQsjwj2+l" | |
# Check if known_hosts file exists, if not create it | |
KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts" | |
if [ ! -f "$KNOWN_HOSTS_FILE" ]; then | |
touch "$KNOWN_HOSTS_FILE" | |
chmod 644 "$KNOWN_HOSTS_FILE" | |
fi | |
# Add the host key to the known_hosts file if it is not already present | |
grep -qxF "$REPO_PUBLIC_KEY" "$KNOWN_HOSTS_FILE" || echo "$REPO_PUBLIC_KEY" >> "$KNOWN_HOSTS_FILE" | |
- name: Build RonDB Tarball | |
run: | | |
BUILD_CORES=$(nproc) | |
echo "Building RonDB tarball with $BUILD_CORES cores" | |
EXTRA_ARGS="--build-arg RELEASE_TARBALL=1" | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
if [ "${{ github.event.inputs.release_build }}" == "false" ]; then | |
EXTRA_ARGS="" | |
fi | |
fi | |
docker buildx build . \ | |
-f Dockerfile.oraclelinux8 \ | |
--target get-package-all \ | |
--output . \ | |
--build-arg BUILD_THREADS=$BUILD_CORES \ | |
$EXTRA_ARGS | |
ls -l | |
- name: Upload RonDB Tarball | |
run: | | |
tarball=$(ls rondb-*.tar.gz 2>/dev/null) | |
count=$(echo "$tarball" | wc -w) | |
if [[ $count -eq 0 ]]; then | |
echo "No tarball found starting with 'rondb-'" | |
exit 1 | |
elif [[ $count -gt 1 ]]; then | |
echo "Multiple tarballs found starting with 'rondb-':" | |
echo "$tarball" | |
exit 1 | |
fi | |
echo "Found tarball: $tarball" | |
host_user="$REPO_HOPSWORKS_USER@$REPO_HOPSWORKS_HOSTNAME" | |
# We won't upload to repo.hops.works/master directly; | |
# This is handled by a cron job that checks whether the | |
# tarball already exists first | |
user_code_path="/home/$REPO_HOPSWORKS_USER/upload_area/master" | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
# This will be copied to /opt/repository/master/rondb-dev | |
user_code_path="${user_code_path}/rondb-dev" | |
fi | |
ssh $host_user "mkdir -p $user_code_path" | |
echo "Copying $tarball to $host_user:$user_code_path" | |
scp ./$tarball $host_user:$user_code_path/$tarball | |
# Delete the tarball after it has been uploaded | |
rm -f $tarball |