Commit 10d63818 authored by noplanman's avatar noplanman

Merge branch 'gitlab-ci-tests' into 'master'

Gitlab ci tests

See merge request noplanman/borg-binary-builder!1
parents c2de5f9a 9e0321be
variables:
VERSION: $CI_COMMIT_TAG
stages:
- build
- deploy
armv5:
extends: .main
variables: {ARCH: armel, NAME: "borg-${VERSION}-armv5"}
armv7:
extends: .main
variables: {ARCH: armv7hf, NAME: "borg-${VERSION}-armv7"}
arm64:
extends: .main
variables: {ARCH: aarch64, NAME: "borg-${VERSION}-arm64"}
.main:
stage: build
only: [tags]
variables: {NAME: "borg-${VERSION}-${ARCH}"}
script:
- ./build.sh $ARCH $VERSION
- ./extract.sh $ARCH $VERSION $NAME
artifacts:
expire_in: 1 day
paths: [$NAME]
deploy artifacts to bintray:
stage: deploy
only: [tags]
script:
- md5sum borg-${VERSION}-*
- apk add curl
- ci/bintray.sh
dependencies:
- armv5
- armv7
- arm64
sudo: required
language: bash
services:
- docker
before_install:
- docker -v
- mkdir /tmp/borg-binaries
script:
- ./build.sh $ARCH
- ./extract.sh $ARCH /tmp/borg-binaries/$NAME
after_script:
- md5sum /tmp/borg-binaries/*
env:
- ARCH="armel" NAME="armv5"
- ARCH="armv7hf" NAME="armv7"
- ARCH="aarch64" NAME="arm64"
......@@ -19,12 +19,12 @@ RUN set -ex; \
zlib1g-dev liblz4-dev; \
rm -rf /var/lib/apt/lists/*;
# install borg + dependencies
# fetch borg source code and update pip
RUN set -ex; \
git clone https://github.com/borgbackup/borg.git .; \
git checkout ${BORG_VERSION}; \
git clone -b ${BORG_VERSION} https://github.com/borgbackup/borg.git .; \
pip install --upgrade pip;
# install borg + dependencies
RUN set -ex; pip install -r requirements.d/development.txt;
RUN set -ex; pip install -r requirements.d/fuse.txt;
RUN set -ex; pip install -e .;
......
......@@ -19,16 +19,16 @@ See the [list of available architectures] ([on GitHub][available-architectures-g
### Extract borg binary
`./extract.sh <arch> [<binary_save_location>]`
`./extract.sh <arch> [<version>] [<binary_save_location>]`
**Note:** This will overwrite the file at `binary_save_location` if it already exists!
*Examples:*
- Extract borg binary for `aarch64` to `borg-aarch64` in current folder
`./extract.sh aarch64 borg-aarch64`
- Extract borg `1.1.7` binary for `aarch64` to `borg-aarch64` in current folder
`./extract.sh aarch64 1.1.7 borg-aarch64`
- Extract borg binary for Raspberry Pi 3 to `/homes/lemoi/borg`
`./extract.sh raspberrypi3 /homes/lemoi/borg`
- Extract borg `1.1.5` binary for Raspberry Pi 3 to `/homes/lemoi/borg`
`./extract.sh raspberrypi3 1.1.5 /homes/lemoi/borg`
## How this works
......
#!/usr/bin/env bash
#!/usr/bin/env sh
# Usage: ./build.sh <arch> [<version>]
......@@ -8,9 +8,11 @@
BORG_ARCH=${1}
BORG_VERSION=${2:-1.1.7}
DOCKER_IMAGE=borg:${BORG_VERSION}-${BORG_ARCH}
if [ -z "${BORG_ARCH}" ]; then
echo "Usage: ./build.sh <arch> [<version>]";
echo "- No arch provided -";
echo "No arch provided";
exit 1;
fi
......@@ -22,4 +24,4 @@ docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build \
--build-arg "BORG_ARCH=${BORG_ARCH}" \
--build-arg "BORG_VERSION=${BORG_VERSION}" \
-t "borg:${BORG_ARCH}" .
-t "${DOCKER_IMAGE}" .
#!/usr/bin/env sh
# Based on bintray.sh by Lukas Matt (@zauberstuhl)
# https://git.feneas.org/ganggo/ganggo/blob/master/ci/scripts/bintray.sh
# Note: Set via GitLab protected vars!
# BINTRAY_USER=$1
# BINTRAY_API_KEY=$2
# BINTRAY_REPO=$3
PKG_NAME=borg-binaries
API=https://api.bintray.com
CURL="curl -u${BINTRAY_USER}:${BINTRAY_API_KEY} -H Content-Type:application/json -H Accept:application/json"
DATA="{
\"name\": \"${PKG_NAME}\",
\"desc\": \"BorgBackup binaries for various architectures\",
\"vcs_url\": \"${CI_PROJECT_URL}\",
\"licenses\": [\"WTFPL\"],
\"issue_tracker_url\": \"${CI_PROJECT_URL}/issues\",
\"website_url\": \"${CI_PROJECT_URL}\",
\"desc_url\": \"${CI_PROJECT_URL}\",
\"labels\": [\"borg\", \"borgbackup\", \"binaries\"],
\"public_download_numbers\": true,
\"public_stats\": true
}"
echo "Creating package ${PKG_NAME}..."
${CURL} -X POST -d "${DATA}" "${API}/packages/${BINTRAY_REPO}"
for BIN in $(ls borg-${VERSION}-*); do
LOG=$(mktemp)
ARCH=$(echo "${BIN}" | cut -d/ -f4 | cut -d- -f3)
UPSTREAM="borg-${VERSION}-${ARCH}"
STATUS_CODE=$(
${CURL} --write-out %{http_code} --silent --output "${LOG}" \
-T "${BIN}" -H X-Bintray-Package:"${PKG_NAME}" -H X-Bintray-Version:"${VERSION}" \
"${API}/content/${BINTRAY_REPO}/${UPSTREAM}"
)
if [ $STATUS_CODE -eq 201 ]; then
echo "Publishing ${UPSTREAM}..."
echo $(
${CURL} -X POST -d "{ \"discard\": \"false\" }" \
${API}/content/${BINTRAY_REPO}/${PKG_NAME}/${VERSION}/publish
)
else
echo "Cannot publish ${UPSTREAM}!" && cat ${LOG} && exit 1
fi
rm "${LOG}"
done
#!/usr/bin/env bash
#!/usr/bin/env sh
# Usage: ./extract.sh <arch> [<binary_save_location>]
# Usage: ./extract.sh <arch> [<version>] [<binary_save_location>]
BORG_ARCH=${1:-aarch64}
BORG_BINARY=${2:-borg-${BORG_ARCH}}
BORG_ARCH=${1}
BORG_VERSION=${2:-1.1.7}
BORG_BINARY=${3:-borg-${BORG_VERSION}-${BORG_ARCH}}
#if [[ "$(docker images -q "borg:${BORG_ARCH}" 2> /dev/null)" == "" ]]; then
if ! docker inspect "borg:${BORG_ARCH}" >/dev/null 2>&1; then
echo "Couldn't find the 'borg:${BORG_ARCH}' image!"
echo "Create the image first, using './build.sh ${BORG_ARCH}'"
exit 1
DOCKER_IMAGE=borg:${BORG_VERSION}-${BORG_ARCH}
if [ -z "${BORG_ARCH}" ]; then
echo "Usage: ./build.sh <arch> [<version>]";
echo "No arch provided";
exit 1;
fi
#docker run -v "${PWD}":"/opt/mount" --rm --entrypoint \
# cp "borg:${BORG_ARCH}" "/usr/bin/borg" "/opt/mount/${BORG_BINARY}"
if ! docker inspect "${DOCKER_IMAGE}" >/dev/null 2>&1; then
echo "Couldn't find the '${DOCKER_IMAGE}' docker image!"
echo "Create the image first, using './build.sh ${BORG_ARCH} ${BORG_VERSION}'"
exit 1
fi
docker run --rm --entrypoint cat "borg:${BORG_ARCH}" /usr/bin/borg > "${BORG_BINARY}"
docker run --rm --entrypoint cat "${DOCKER_IMAGE}" /usr/bin/borg > "${BORG_BINARY}"
chmod +x "${BORG_BINARY}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment