-
Notifications
You must be signed in to change notification settings - Fork 45
130 lines (109 loc) · 4.37 KB
/
publish_rondb.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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