Initial CI
All checks were successful
continuous-integration/drone Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Aode (lion) 2021-12-22 15:43:39 -06:00
parent 99f48e858d
commit 250b1afd7b
6 changed files with 182 additions and 221 deletions

152
.drone.yml Normal file
View file

@ -0,0 +1,152 @@
kind: pipeline
type: docker
name: publish-amd64
platform:
arch: amd64
steps:
- name: push
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
auto_tag: true
auto_tag_suffix: linux-amd64
build_args:
- TARGET=x86_64-unknown-linux-musl
- TOOL=x86_64-linux-musl
- name: latest
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
tag: latest-linux-amd64
build_args:
- TARGET=x86_64-unknown-linux-musl
- TOOL=x86_64-linux-musl
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: publish-arm64v8
platform:
arch: amd64
steps:
- name: push
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
auto_tag: true
auto_tag_suffix: linux-arm64v8
build_args:
- TARGET=aarch64-unknown-linux-musl
- TOOL=aarch64-linux-musl
- name: latest
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
tag: latest-linux-arm64v8
build_args:
- TARGET=aarch64-unknown-linux-musl
- TOOL=aarch64-linux-musl
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: publish-arm32v7
platform:
arch: amd64
steps:
- name: push
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
auto_tag: true
auto_tag_suffix: linux-arm32v7
build_args:
- TARGET=armv7-unknown-linux-musleabihf
- TOOL=armv7-linux-musleabihf
- name: latest
image: plugins/docker:20
settings:
username: asonix
password:
from_secret: dockerhub_token
repo: asonix/rust-builder
dockerfile: Dockerfile
tag: latest-linux-arm32v7
build_args:
- TARGET=armv7-unknown-linux-musleabihf
- TOOL=armv7-linux-musleabihf
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: cron
clone:
disable: true
steps:
- name: clone
image: alpine/git:latest
user: root
commands:
- git clone $DRONE_GIT_HTTP_URL .
- git checkout $DRONE_COMMIT
- chown -R 991:991 .
- name: tag
image: asonix/release-checker:0.1
pull: always
environment:
GITEA_TOKEN:
from_secret: gitea_token
commands:
- /usr/local/bin/release-checker
trigger:
event:
- custom
- cron

7
Check.toml Normal file
View file

@ -0,0 +1,7 @@
[project]
kind = "none"
[gitea]
domain = "git.asonix.dog"
owner = "asonix"
repo = "rust-builder"

View file

@ -1,48 +1,48 @@
ARG TARGET=aarch64-unknown-linux-musl
ARG TARGET
# build environment
FROM rustembedded/cross:$TARGET
ARG UID=991
ARG GID=991
ARG TARGET=aarch64-unknown-linux-musl
ARG TOOL=aarch64-linux-musl
ARG TARGET
ARG TOOL
ARG BUILD_MODE=release
ENV \
UID=${UID} \
GID=${GID} \
TARGET=${TARGET} \
TOOL=${TOOL} \
BUILD_MODE=${BUILD_MODE} \
TOOLCHAIN=stable
UID=${UID} \
GID=${GID} \
TARGET=${TARGET} \
TOOL=${TOOL} \
BUILD_MODE=${BUILD_MODE} \
TOOLCHAIN=stable
RUN \
addgroup --gid "${GID}" build && \
adduser \
--disabled-password \
--gecos "" \
--ingroup build \
--uid "${UID}" \
--home /opt/build \
build
addgroup --gid "${GID}" build && \
adduser \
--disabled-password \
--gecos "" \
--ingroup build \
--uid "${UID}" \
--home /opt/build \
build
ADD \
https://sh.rustup.rs /opt/build/rustup.sh
https://sh.rustup.rs /opt/build/rustup.sh
RUN \
chown -R build:build /opt/build
chown -R build:build /opt/build
USER build
WORKDIR /opt/build
ENV \
PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin
PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin
RUN \
chmod +x rustup.sh && \
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
rustup target add $TARGET
chmod +x rustup.sh && \
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
rustup target add $TARGET
USER build

View file

@ -1,82 +0,0 @@
#!/usr/bin/env bash
function require() {
if [ "$1" = "" ]; then
echo "input '$2' required"
print_help
exit 1
fi
}
function print_help() {
echo "deploy.sh"
echo ""
echo "Usage:"
echo " deploy.sh [repo] [tag] [arch]"
echo ""
echo "Args:"
echo " repo: The docker repository to publish the image"
echo " tag: The tag applied to the docker image"
echo " arch: The architecuture of the doker image"
}
function build() {
REPO=$1
ARCH=$2
TAG=$3
TARGET=$4
TOOL=$5
sudo docker build \
--no-cache \
--pull \
--build-arg TAG=$TAG \
--build-arg TARGET=$TARGET \
--build-arg TOOL=$TOOL \
--build-arg ARCH_REPO=$ARCH \
-t $REPO:$ARCH-$TAG \
-f Dockerfile \
.
}
REPO=$1
TAG=$2
ARCH=$3
require "$REPO" "repo"
require "$TAG" "tag"
require "$ARCH" "arch"
case $ARCH in
amd64)
build \
"$REPO" \
"$ARCH" \
"$TAG" \
x86_64-unknown-linux-musl \
x86_64-linux-musl
;;
arm32v7)
build \
"$REPO" \
"$ARCH" \
"$TAG" \
armv7-unknown-linux-musleabihf \
arm-linux-musleabihf
;;
arm64v8)
build \
"$REPO" \
"$ARCH" \
"$TAG" \
aarch64-unknown-linux-musl \
aarch64-linux-musl
;;
*)
echo "Invalid architecture provided"
exit 1
;;
esac

View file

@ -1,73 +0,0 @@
#!/usr/bin/env bash
function require() {
if [ "$1" = "" ]; then
echo "input '$2' required"
print_help
exit 1
fi
}
function print_help() {
echo "build.sh"
echo ""
echo "Usage:"
echo " build.sh [tag] [branch] [push]"
echo ""
echo "Args:"
echo " tag: The git tag to be applied to the repository and docker build"
echo " branch: The git branch to use for tagging and publishing"
echo " push: Whether or not to push the image"
echo ""
echo "Examples:"
echo " ./build.sh v0.3.0-alpha.13 main true"
echo " ./build.sh v0.3.0-alpha.13-shell-out asonix/shell-out false"
}
function build_image() {
tag=$1
arch=$2
push=$3
./build-image.sh asonix/rust-builder $tag $arch
sudo docker tag asonix/rust-builder:$arch-$tag asonix/rust-builder:$arch-latest
if [ "$push" == "true" ]; then
sudo docker push asonix/rust-builder:$arch-$tag
sudo docker push asonix/rust-builder:$arch-latest
fi
}
# Creating the new tag
new_tag="$1"
branch="$2"
push=$3
require "$new_tag" "tag"
require "$branch" "branch"
require "$push" "push"
if ! sudo docker run --rm -it arm64v8/alpine:3.11 /bin/sh -c 'echo "docker is configured correctly"'
then
echo "docker is not configured to run on qemu-emulated architectures, fixing will require sudo"
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi
git commit -m "Version $new_tag"
set -xe
git tag $new_tag
git push origin $new_tag
git push
build_image $new_tag arm64v8 $push
build_image $new_tag arm32v7 $push
build_image $new_tag amd64 $push
if [ "$push" == "true" ]; then
./manifest.sh rust-builder $new_tag
./manifest.sh rust-builder latest
fi

View file

@ -1,43 +0,0 @@
#!/usr/bin/env bash
function require() {
if [ "$1" = "" ]; then
echo "input '$2' required"
print_help
exit 1
fi
}
function print_help() {
echo "deploy.sh"
echo ""
echo "Usage:"
echo " manifest.sh [repo] [tag]"
echo ""
echo "Args:"
echo " repo: The docker repository to update"
echo " tag: The git tag to be applied to the image manifest"
}
REPO=$1
TAG=$2
require "$REPO" "repo"
require "$TAG" "tag"
set -xe
sudo docker manifest create asonix/$REPO:$TAG \
-a asonix/$REPO:arm64v8-$TAG \
-a asonix/$REPO:arm32v7-$TAG \
-a asonix/$REPO:amd64-$TAG
sudo docker manifest annotate asonix/$REPO:$TAG \
asonix/$REPO:arm64v8-$TAG --os linux --arch arm64 --variant v8
sudo docker manifest annotate asonix/$REPO:$TAG \
asonix/$REPO:arm32v7-$TAG --os linux --arch arm --variant v7
sudo docker manifest annotate asonix/$REPO:$TAG \
asonix/$REPO:amd64-$TAG --os linux --arch amd64
sudo docker manifest push asonix/$REPO:$TAG --purge