-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement mysql client building in both architectures
- Loading branch information
Showing
7 changed files
with
257 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Build | ||
on: | ||
push: | ||
|
||
workflow_dispatch: | ||
inputs: | ||
debug_enabled: | ||
description: 'Run the build with tmate set "debug_enabled"' | ||
type: boolean | ||
required: false | ||
default: false | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
BUILDKIT_PROGRESS: plain | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
dbversion: ["5.7.44", "8.0.36"] | ||
arch: ["amd64"] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
with: | ||
limit-access-to-actor: true | ||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | ||
|
||
- name: Run basic docker container | ||
run: | | ||
docker run --rm debian:bookworm bash -c 'arch && cat /etc/*release*' | ||
- name: Set up for multi-arch | ||
run: sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
|
||
- name: Build mysql clients | ||
run: | | ||
./build-clients.sh --mysql-version ${{ matrix.dbversion }} --arch ${{ matrix.arch }} | ||
- name: "Tar up the binaries" | ||
run: | | ||
tar -C ./mysql_${{ matrix.dbversion }}/built_${{ matrix.dbversion }}_${{ matrix.arch }}/bin/ -czf ./mysql-${{ matrix.dbversion }}-${{ matrix.arch }}.tar.gz . | ||
- name: "upload mysql-${{ matrix.dbversion }}-${{ matrix.arch }}" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mysql-${{ matrix.dbversion }}-${{ matrix.arch }} | ||
path: "./mysql-${{ matrix.dbversion }}-${{ matrix.arch }}.tar.gz" | ||
|
||
- name: Setup tmate session | ||
if: ${{ failure() }} | ||
uses: mxschmitt/action-tmate@v3 | ||
|
||
release: | ||
runs-on: ubuntu-24.04 | ||
needs: tests | ||
if: startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: ./artifacts | ||
|
||
- name: Show content of ./artifacts | ||
run: ls -lR ./artifacts | ||
|
||
- name: Add files to release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: ./artifacts/*/*.tar.gz | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup tmate session | ||
if: ${{ failure() }} | ||
uses: mxschmitt/action-tmate@v3 | ||
|
||
# - name: Upload Release Assets | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# run: | | ||
# for file in $(find ./artifacts -type f); do | ||
# gh release upload "${{ github.ref }}" "$file" --clobber | ||
# done |
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,2 @@ | ||
/mysql_* | ||
/built-* |
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 |
---|---|---|
@@ -1,2 +1,34 @@ | ||
# cmake | ||
Build things with cmake | ||
# mysql-client-build | ||
|
||
Build various versions of the mysql clients (mysql, mysqldump) | ||
|
||
Primarily intended for [DDEV](https://github.com/ddev/ddev)'s `ddev-webserver` | ||
|
||
See [issue](https://github.com/ddev/ddev/issues/6083). | ||
|
||
## Docker Image | ||
|
||
A Docker image is used to do the build, so that we have the right upstream environment, currently Debian 12 Bookworm, and the right architecture (amd64/arm64). | ||
|
||
If updates need to be made to the image: | ||
|
||
`cd image && ./push` | ||
|
||
## Running the build script | ||
|
||
The build script is `build-clients.sh` and it can be run with something like: | ||
|
||
`./build-clients.sh --mysql-version 5.7.44 --arch amd64` | ||
|
||
## Building with GitHub Release | ||
|
||
Every push builds a set of files that are available on the test page. | ||
|
||
But mostly a new release will create a set of tarballs for each version and architecture. | ||
|
||
You can update the list of things to be built in the "strategy" section of .github/workflows/tests.yaml | ||
|
||
## When to build | ||
|
||
Luckily, this doesn't have to be built too terribly often. Mostly it's only when we have a new mysql server version to deploy. | ||
|
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,68 @@ | ||
#!/bin/bash | ||
|
||
# Build mysql clients for a particular mysql version and architecture | ||
# ./build-clients.sh --mysql-version 8.0.36 --arch arm64 | ||
|
||
set -eu -o pipefail | ||
|
||
usage() { | ||
echo "Usage: $0 --mysql-version <version> --arch <architecture>" | ||
exit 1 | ||
} | ||
|
||
if [ $# -eq 0 ]; then | ||
usage | ||
fi | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case "$1" in | ||
--mysql-version) | ||
if [ -n "${2-}" ]; then | ||
MYSQL_VERSION="$2" | ||
shift 2 | ||
else | ||
echo "Error: --mysql-version requires a value" | ||
usage | ||
fi | ||
;; | ||
--arch) | ||
if [ -n "${2-}" ]; then | ||
ARCH="$2" | ||
shift 2 | ||
else | ||
echo "Error: --arch requires a value" | ||
usage | ||
fi | ||
;; | ||
*) | ||
echo "Error: Invalid option $1" | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
# Check if both options are set | ||
if [ -z "$MYSQL_VERSION" ] || [ -z "$ARCH" ]; then | ||
usage | ||
fi | ||
|
||
|
||
echo "MySQL Version: $MYSQL_VERSION" | ||
echo "Architecture: ${ARCH}" | ||
|
||
set -x | ||
|
||
docker pull randyfay/cmake | ||
|
||
if [ ! -d mysql_${MYSQL_VERSION} ]; then | ||
curl -L --fail -o /tmp/mysql.tgz https://dev.mysql.com/get/Downloads/MySQL-${MYSQL_VERSION%.?}/mysql-${MYSQL_VERSION}.tar.gz | ||
mkdir -p mysql_${MYSQL_VERSION} | ||
tar -C mysql_${MYSQL_VERSION} --strip-components=1 -zxf /tmp/mysql.tgz | ||
fi | ||
pushd mysql_${MYSQL_VERSION} | ||
echo "Building ${ARCH} for mysql ${MYSQL_VERSION}" | ||
docker run --rm --platform=linux/${ARCH} -e MYSQL_VERSION=${MYSQL_VERSION} -e ARCH=${ARCH} -v .:/src randyfay/cmake | ||
|
||
popd | ||
|
||
|
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,26 @@ | ||
FROM debian:bookworm | ||
ARG TARGETARCH | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
cmake \ | ||
git \ | ||
libsasl2-dev \ | ||
libssl-dev \ | ||
libncurses5-dev \ | ||
bison \ | ||
pkg-config \ | ||
libtirpc-dev | ||
|
||
WORKDIR /src | ||
|
||
## Checkout MySQL 8.0 branch | ||
#RUN git checkout mysql-8.0 | ||
|
||
# Build script | ||
COPY build-mysql-clients.sh /build-mysql-clients.sh | ||
RUN chmod +x /build-mysql-clients.sh | ||
|
||
# Define default command | ||
CMD ["/build-mysql-clients.sh"] |
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,20 @@ | ||
#!/bin/bash | ||
|
||
set -eu -o pipefail | ||
|
||
set -x | ||
|
||
BUILDDIR=build_${ARCH} | ||
rm -rf ${BUILDDIR} | ||
mkdir -p ${BUILDDIR} | ||
# OUTPUTDIR contructed from required MYSQL_VERSION and ARCH | ||
OUTPUTDIR="/src/built_${MYSQL_VERSION}_${ARCH}" | ||
|
||
cmake -B${BUILDDIR} -H. -DWITHOUT_SERVER=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost -DCMAKE_INSTALL_PREFIX=${OUTPUTDIR} | ||
cd ${BUILDDIR} | ||
make mysql mysqldump | ||
make install | ||
|
||
# Output version to verify version and arch | ||
${OUTPUTDIR}/bin/mysql --version | ||
${OUTPUTDIR}/bin/mysqldump --version |
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,8 @@ | ||
#!/bin/bash | ||
|
||
set -eu -o pipefail | ||
DOCKER_IMAGE=randyfay/cmake | ||
|
||
docker buildx create --name cmake --use 2>/dev/null || true | ||
|
||
docker buildx build --push --platform linux/amd64,linux/arm64 -t ${DOCKER_IMAGE} . |